public class InvokeActionEventListener extends DefaultPhaseListener implements SystemEventListener
The InvokeActionEventListener will add support for new <f:event> types
preInvokeAction and postInvokeAction. Those events are published during the beforephase and
afterphase of INVOKE_APPLICATION respectively. This actually offers a better hook on invoking actions
after the <f:viewParam> values been set than the preRenderView event. In some
circumstances the preRenderView event might be too late. For example, when you need to set a faces
message in the flash scope and send a redirect. Also, it won't be invoked when the validations phase has failed for
one of the <f:viewParam> values, in contrary to the preRenderView event.
Note that the upcoming JSF 2.2 will come with a <f:viewAction> tag which should actually solve
the concrete functional requirement for which a <f:event type="preRenderView"> workaround is often
been used in JSF 2.0 and 2.1.
This event is supported on any UIComponent, including UIViewRoot, UIForm, UIInput and
UICommand components. This thus also provides the possibility to invoke multiple action listeners on a single
UIInput and UICommand component on an easy manner.
As this phase listener has totally no impact on a webapp's default behavior, 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 endusers do not need to register this phase listener explicitly themselves.
PreInvokeActionEvent,
PostInvokeActionEvent,
Serialized Form| Constructor and Description |
|---|
InvokeActionEventListener()
This constructor instructs the
DefaultPhaseListener to hook on PhaseId.INVOKE_APPLICATION and
subscribes this instance as a SystemEventListener to the PostValidateEvent event. |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPhase(PhaseEvent event)
Publish the
PostInvokeActionEvent event on the components which are been collected in
processEvent(SystemEvent). |
void |
beforePhase(PhaseEvent event)
Publish the
PreInvokeActionEvent event on the components which are been collected in
processEvent(SystemEvent). |
boolean |
isListenerForSource(Object source)
Returns
true only when the given source is an UIComponent which has listeners for
PreInvokeActionEvent or PostInvokeActionEvent. |
void |
processEvent(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. |
getPhaseIdpublic InvokeActionEventListener()
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.public boolean isListenerForSource(Object source)
true only when the given source is an UIComponent which has listeners for
PreInvokeActionEvent or PostInvokeActionEvent.isListenerForSource in interface SystemEventListenerpublic void processEvent(SystemEvent event) throws AbortProcessingException
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.processEvent in interface SystemEventListenerAbortProcessingExceptionpublic void beforePhase(PhaseEvent event)
PreInvokeActionEvent event on the components which are been collected in
processEvent(SystemEvent).beforePhase in interface PhaseListenerbeforePhase in class DefaultPhaseListenerpublic void afterPhase(PhaseEvent event)
PostInvokeActionEvent event on the components which are been collected in
processEvent(SystemEvent).afterPhase in interface PhaseListenerafterPhase in class DefaultPhaseListenerCopyright © 2012–2015 OmniFaces. All rights reserved.