public final class Events extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addAfterPhaseListener(PhaseId phaseId,
Callback.Void callback)
Adds a phase listener to the current view that invokes the given callback every time after given phase.
|
static void |
addBeforePhaseListener(PhaseId phaseId,
Callback.Void callback)
Adds a phase listener to the current view that invokes the given callback every time before given phase ID.
|
static void |
addPhaseListener(PhaseListener phaseListener)
Adds a phase listener to the current view root of the current faces context.
|
static PhaseListener |
createAfterPhaseListener(PhaseId phaseId,
Callback.Void callback)
Creates a phase listener that invokes the given callback every time after the given phase.
|
static PhaseListener |
createBeforePhaseListener(PhaseId phaseId,
Callback.Void callback)
Creates a phase listener that invokes the given callback every time before the given phase.
|
static void |
removeCallbackPhaseListener()
Removes the one and only phase listener from callbacks by the global phase listener for the current request.
|
static void |
removePhaseListener(PhaseListener phaseListener)
Removes a phase listener from the current view root of the current faces context.
|
static void |
setCallbackAfterPhaseListener(PhaseId phaseId,
Callback.Void callback)
Sets a phase listener for callback by a global phase listener during the current request that invokes the
given callback every time after given phase ID.
|
static void |
setCallBackBeforePhaseListener(PhaseId phaseId,
Callback.Void callback)
Sets a phase listener for callback by a global phase listener during the current request that invokes the
given callback every time before given phase ID.
|
static void |
setCallbackPhaseListener(PhaseListener phaseListener)
Sets phase listener for callback by a global phase listener during the current request.
|
static void |
subscribeToEvent(Class<? extends SystemEvent> type,
SystemEventListener listener)
Adds the given system event listener to the application that get invoked every time when the given system event
type is published.
|
static void |
subscribeToViewEvent(Class<? extends SystemEvent> type,
Callback.Void callback)
Install the callback instance referenced by argument listener into the UIViewRoot as a listener for events of type systemEventClass.
|
static void |
subscribeToViewEvent(Class<? extends SystemEvent> type,
SystemEventListener listener)
Install the listener instance referenced by argument listener into the UIViewRoot as a listener for events of type systemEventClass.
|
public static void addPhaseListener(PhaseListener phaseListener)
phaseListener
- The phase listener to be added to the current view root of the current faces context.public static void removePhaseListener(PhaseListener phaseListener)
phaseListener
- The phase listener to be removed from the current view root of the current faces context.public static void setCallbackPhaseListener(PhaseListener phaseListener)
This differs in a few subtle ways from addPhaseListener(PhaseListener)
. Namely, the phase listener
registered here will be called via the global phase listener, which executes slightly earlier for its before phase
and slightly later for its after phase as compared to phase listeners attached to the view root.
Additionally, a phase listener registered via this method will not become part of the view state, but will execute only once. Phase listeners attached to the view root will come back after each postback and have to be remove manually (in Mojarra this can be difficult due to the fact iterators over listeners are kept 'open' during each phase).
Note: at the moment only 1 callback phase listener per request can be set.
phaseListener
- The phase listener to be set for callback during the current request.public static void removeCallbackPhaseListener()
public static void addBeforePhaseListener(PhaseId phaseId, Callback.Void callback)
phaseId
- The phase ID to invoke the given callback every time before.callback
- The callback to be invoked every time before the given phase ID of the current view.public static void addAfterPhaseListener(PhaseId phaseId, Callback.Void callback)
phaseId
- The phase ID to invoke the given callback every time after.callback
- The callback to be invoked every time after the given phase ID of the current view.public static void setCallBackBeforePhaseListener(PhaseId phaseId, Callback.Void callback)
phaseId
- The phase ID to invoke the given callback every time before.callback
- The callback to be invoked every time before the given phase ID of the current request.public static void setCallbackAfterPhaseListener(PhaseId phaseId, Callback.Void callback)
phaseId
- The phase ID to invoke the given callback every time after.callback
- The callback to be invoked every time after the given phase ID of the current request.public static PhaseListener createBeforePhaseListener(PhaseId phaseId, Callback.Void callback)
phaseId
- The phase ID to invoke the given callback every time before.callback
- The callback to be invoked every time before the given phase ID of the current view.public static PhaseListener createAfterPhaseListener(PhaseId phaseId, Callback.Void callback)
phaseId
- The phase ID to invoke the given callback every time after.callback
- The callback to be invoked every time after the given phase ID of the current view.public static void subscribeToEvent(Class<? extends SystemEvent> type, SystemEventListener listener)
type
- The system event type to listen on.listener
- The system event listener to be invoked.public static void subscribeToViewEvent(Class<? extends SystemEvent> type, SystemEventListener listener)
type
- The system event type to listen on.listener
- The system event listener to be invoked.public static void subscribeToViewEvent(Class<? extends SystemEvent> type, Callback.Void callback)
type
- The system event type to listen on.callback
- The callback to be invoked.