org.omnifaces.eventlistener
Class InvokeActionEventListener

java.lang.Object
  extended by org.omnifaces.eventlistener.DefaultPhaseListener
      extended by org.omnifaces.eventlistener.InvokeActionEventListener
All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, javax.faces.event.FacesListener, javax.faces.event.PhaseListener, javax.faces.event.SystemEventListener

public class InvokeActionEventListener
extends DefaultPhaseListener
implements javax.faces.event.SystemEventListener

This phase listener takes care that the PreInvokeActionEvent and PostInvokeActionEvent events are properly published.

This phase listener is already registered by OmniFaces' own faces-config.xml and thus gets auto-initialized when the OmniFaces JAR is bundled in a webapp, so end-users do not need to register this phase listener explicitly themselves.

Since:
1.1
Author:
Bauke Scholtz
See Also:
PreInvokeActionEvent, PostInvokeActionEvent, Serialized Form

Constructor Summary
InvokeActionEventListener()
          This constructor instructs the DefaultPhaseListener to hook on PhaseId.INVOKE_APPLICATION and subscribes this instance as a SystemEventListener to the PostValidateEvent event.
 
Method Summary
 void afterPhase(javax.faces.event.PhaseEvent event)
          Publish the PostInvokeActionEvent event on the components which are been collected in processEvent(SystemEvent).
 void beforePhase(javax.faces.event.PhaseEvent event)
          Publish the PreInvokeActionEvent event on the components which are been collected in processEvent(SystemEvent).
 boolean isListenerForSource(java.lang.Object source)
          Returns true only when the given source is an instance of UIViewRoot, UIForm, UIInput or UICommand.
 void processEvent(javax.faces.event.SystemEvent event)
          If the validation has not failed for the current faces context, then check if the UIComponent which passed the isListenerForSource(Object) check has any listeners for the PreInvokeActionEvent and/or PostInvokeActionEvent events and then add them to a set in the current faces context.
 
Methods inherited from class org.omnifaces.eventlistener.DefaultPhaseListener
getPhaseId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InvokeActionEventListener

public InvokeActionEventListener()
This constructor instructs the DefaultPhaseListener to hook on PhaseId.INVOKE_APPLICATION and subscribes this instance as a SystemEventListener to the PostValidateEvent event. This allows collecting the components eligible for PreInvokeActionEvent or PostInvokeActionEvent inside the processEvent(SystemEvent) method.

Method Detail

isListenerForSource

public boolean isListenerForSource(java.lang.Object source)
Returns true only when the given source is an instance of UIViewRoot, UIForm, UIInput or UICommand.

Specified by:
isListenerForSource in interface javax.faces.event.SystemEventListener

processEvent

public void processEvent(javax.faces.event.SystemEvent event)
                  throws javax.faces.event.AbortProcessingException
If the validation has not failed for the current faces context, then check if the UIComponent which passed the isListenerForSource(Object) check has any listeners for the PreInvokeActionEvent and/or PostInvokeActionEvent events and then add them to a set in the current faces context.

Specified by:
processEvent in interface javax.faces.event.SystemEventListener
Throws:
javax.faces.event.AbortProcessingException

beforePhase

public void beforePhase(javax.faces.event.PhaseEvent event)
Publish the PreInvokeActionEvent event on the components which are been collected in processEvent(SystemEvent).

Specified by:
beforePhase in interface javax.faces.event.PhaseListener
Overrides:
beforePhase in class DefaultPhaseListener

afterPhase

public void afterPhase(javax.faces.event.PhaseEvent event)
Publish the PostInvokeActionEvent event on the components which are been collected in processEvent(SystemEvent).

Specified by:
afterPhase in interface javax.faces.event.PhaseListener
Overrides:
afterPhase in class DefaultPhaseListener