Package com.mendix.core.actionmanagement
Class ActionListener<T extends ICoreAction<?>>
java.lang.Object
com.mendix.core.actionmanagement.ActionListener<T>
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
UserActionListener
Abstract ActionListener
T is the type of ICoreAction this listener listens to. If the check method returns true, the actions defined in before, concurrent and after will be executed.
T is the type of ICoreAction this listener listens to. If the check method returns true, the actions defined in before, concurrent and after will be executed.
-
Constructor Summary
ConstructorsConstructorDescriptionActionListener(Class<T> targetClass) Creates ActionListener with targetClass. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddAfterEvent(String classOrActionName) Registers the specified action as an after event handler.final <R> voidaddAfterEvent(Consumer<IMendixObject> consumer) Registers the specified function as an after event handler.final voidaddBeforeEvent(String classOrActionName) Registers the specified action as a before event handler.final voidaddBeforeEvent(String classOrActionName, boolean raiseExceptionOnFalse) Registers the specified action as a before event handler.final <R> voidaddBeforeEvent(Consumer<IMendixObject> consumer, boolean raiseExceptionOnFalse) Registers the specified function as a before event handler.final voidaddReplaceEvent(String classOrActionName) Registers the specified action as a replace event handler.abstract booleanChecks if this Listener's events must be fired.clone()Deprecated.since 9.24.Create a clone.final List<EventActionInfo> getAfter()Returns all registered after event handlers.final List<EventActionInfo> Returns all registered before event handlers.final StringReturns the registered replace event handler (if any).Returns the type of action this listener listens to.final voidsetTargetClass(Class<T> targetClass) Deprecated.since 9.23.
-
Constructor Details
-
ActionListener
Creates ActionListener with targetClass.- Parameters:
targetClass- the type of action this listener listens to
-
-
Method Details
-
getTargetClass
Returns the type of action this listener listens to.- Returns:
- the target class
-
setTargetClass
Deprecated.since 9.23. Use constructor to specify target class.Sets the type of action this listener listens to the specified target class.- Parameters:
targetClass- the target class to set
-
addBeforeEvent
Registers the specified action as a before event handler.- Parameters:
classOrActionName- the action to register
-
addBeforeEvent
public final <R> void addBeforeEvent(Consumer<IMendixObject> consumer, boolean raiseExceptionOnFalse) Registers the specified function as a before event handler.- Type Parameters:
R- result type of the action, which must be Boolean. This type parameter is not used, and will be removed in Mendix 11 (MX11).- Parameters:
consumer- the function to registerraiseExceptionOnFalse- indicates whether to throw an exception if the function returns false
-
addBeforeEvent
Registers the specified action as a before event handler.- Parameters:
classOrActionName- the action to registerraiseExceptionOnFalse- indicates whether to throw an exception if the action returns false
-
addAfterEvent
Registers the specified action as an after event handler.- Parameters:
classOrActionName- the action to register
-
addAfterEvent
Registers the specified function as an after event handler.- Type Parameters:
R- result type of the action, which should typically be Object because the result is ignored This type parameter is not used, and will be removed in Mendix 11 (MX11).- Parameters:
consumer- the function to register
-
addReplaceEvent
Registers the specified action as a replace event handler.- Parameters:
classOrActionName- the action to register
-
getAfter
Returns all registered after event handlers.- Returns:
- the event handlers
-
getBefore
Returns all registered before event handlers.- Returns:
- the event handlers
-
getReplace
Returns the registered replace event handler (if any).- Returns:
- the replace handler if it was set; null otherwise
-
check
Checks if this Listener's events must be fired.If an action of type T is executed in the Core this function is called with that action as parameter.
If this method returns true, the before/concurrent/after actions of this ActionListener will be executed too.- Parameters:
action- the action to check- Returns:
- true if this Listener's events must be fired if action is executed
-
clone
Deprecated.since 9.24. UsecreateClone()instead.Create a clone.- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
createClone
Create a clone.Currently, this is implemented in terms of
clone(). When deprecatedclone()method is removed, this implementation will be removed and subclasses will need to provide their own implementation.- Returns:
- the cloned object
-