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 |
addCallbackAfterPhaseListener(PhaseId phaseId,
Callback.Void callback)
Adds 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 |
addCallbackBeforePhaseListener(PhaseId phaseId,
Callback.Void callback)
Adds 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 |
addCallbackPhaseListener(PhaseListener phaseListener)
Adds phase listener for callback by a global phase listener during the current request.
|
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 boolean |
removeCallbackPhaseListener(PhaseListener phaseListener)
Removes the given phase listener from callbacks 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 |
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 addCallbackPhaseListener(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).
phaseListener
- The phase listener to be added for callback during the current request.CallbackPhaseListener
public static boolean removeCallbackPhaseListener(PhaseListener phaseListener)
true
if the given phase listener was indeed been added, otherwise false
(and
thus effectively no change has taken place).CallbackPhaseListener
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 addCallbackBeforePhaseListener(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.createBeforePhaseListener(PhaseId, org.omnifaces.util.Callback.Void)
,
addCallbackPhaseListener(PhaseListener)
public static void addCallbackAfterPhaseListener(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.createAfterPhaseListener(PhaseId, org.omnifaces.util.Callback.Void)
,
addCallbackPhaseListener(PhaseListener)
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.