Class ActionListener<T extends ICoreAction<?>>

java.lang.Object
com.mendix.core.actionmanagement.ActionListener<T>
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
UserActionListener

public abstract class ActionListener<T extends ICoreAction<?>> extends Object implements Cloneable
Abstract ActionListener
T is the type of ICoreAction this listener listens to. If the check method returns true, the actions registered using the addBeforeEvent(String), addAfterEvent(String) and setReplaceEvent(String) will be executed.
  • Constructor Details

    • ActionListener

      public ActionListener(Class<T> targetClass)
      Creates ActionListener with targetClass.
      Parameters:
      targetClass - the type of action this listener listens to
  • Method Details

    • getTargetClass

      public final Class<T> getTargetClass()
      Returns the type of action this listener listens to.
      Returns:
      the target class
    • addBeforeEvent

      public final void addBeforeEvent(String classOrActionName)
      Registers the specified action as a before event handler.
      Parameters:
      classOrActionName - the action to register
    • addBeforeEvent

      public final void addBeforeEvent(Consumer<IMendixObject> consumer, boolean raiseExceptionOnFalse)
      Registers the specified function as a before event handler.
      Parameters:
      consumer - the function to register
      raiseExceptionOnFalse - indicates whether to throw an exception if the function returns false
    • addBeforeEvent

      public final void addBeforeEvent(String classOrActionName, boolean raiseExceptionOnFalse)
      Registers the specified action as a before event handler.
      Parameters:
      classOrActionName - the action to register
      raiseExceptionOnFalse - indicates whether to throw an exception if the action returns false
    • addAfterEvent

      public final void addAfterEvent(String classOrActionName)
      Registers the specified action as an after event handler.
      Parameters:
      classOrActionName - the action to register
    • addAfterEvent

      public final void addAfterEvent(Consumer<IMendixObject> consumer)
      Registers the specified function as an after event handler.
      Parameters:
      consumer - the function to register
    • addReplaceEvent

      @Deprecated public final void addReplaceEvent(String classOrActionName)
      Deprecated.
      since 11.0.0. This will be removed in Mendix 12. Use setReplaceEvent(String) instead.
      Registers the specified action as a replace event handler.
      Parameters:
      classOrActionName - the action to register
    • setReplaceEvent

      public final void setReplaceEvent(String classOrActionName)
      Registers the specified action as a replace event handler. Only one replace event handler can be registered at a time.
      Parameters:
      classOrActionName - the action to register
    • getAfter

      public final List<EventActionInfo> getAfter()
      Returns all registered after event handlers.
      Returns:
      the event handlers
    • getBefore

      public final List<EventActionInfo> getBefore()
      Returns all registered before event handlers.
      Returns:
      the event handlers
    • getReplace

      public final String getReplace()
      Returns the registered replace event handler (if any).
      Returns:
      the replace handler if it was set; null otherwise
    • check

      public abstract boolean check(T action)
      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
    • createClone

      @Deprecated public ActionListener<T> createClone()
      Deprecated.
      since 11.0. There is no replacement, this method was meant for internal use only. This method will be removed in Mendix 12.
      Create a clone. This method is meant for internal use only.
      Returns:
      the cloned object