public final class Events extends Object
Collection of utility methods for the JSF API with respect to working with system and phase events.
Some examples:
// Add a callback to the current view which should run during every after phase of the render response on same view. Events.subscribeToViewAfterPhase(PhaseId.RENDER_RESPONSE, new Callback.Void() { @Override public void invoke() { // ... } });
// Add a callback to the current request which should run during before phase of the render response on current request. Events.subscribeToRequestBeforePhase(PhaseId.RENDER_RESPONSE, new Callback.Void() { @Override public void invoke() { // ... } });
// Add a callback to the current view which should run during the pre render view event. Events.subscribeToViewEvent(PreRenderViewEvent.class, new Callback.Void() { @Override public void invoke() { // ... } });
Note that you can specify any phase ID or system event to your choice.
Modifier and Type | Method and Description |
---|---|
static void |
addRequestPhaseListener(PhaseListener listener)
Adds the given phase listener to the current request.
|
static void |
addViewPhaseListener(PhaseListener listener)
Adds the given phase listener to the current view.
|
static void |
subscribeToApplicationEvent(Class<? extends SystemEvent> type,
Callback.Void callback)
Subscribe the given callback to the current application that get invoked every time when the given
system event type is published in the current application.
|
static void |
subscribeToApplicationEvent(Class<? extends SystemEvent> type,
Callback.WithArgument<SystemEvent> callback)
Subscribe the given callback to the current application that get invoked every time when the given
system event type is published in the current application.
|
static void |
subscribeToApplicationEvent(Class<? extends SystemEvent> type,
SystemEventListener listener)
Subscribe the given system event listener to the current application that get invoked every time when the given
system event type is published in the current application.
|
static void |
subscribeToRequestAfterPhase(PhaseId phaseId,
Callback.Void callback)
Subscribe the given callback instance to the current request that get invoked after given phase ID.
|
static void |
subscribeToRequestAfterPhase(PhaseId phaseId,
Callback.WithArgument<PhaseEvent> callback)
Subscribe the given callback instance to the current request that get invoked after given phase ID.
|
static void |
subscribeToRequestBeforePhase(PhaseId phaseId,
Callback.Void callback)
Subscribe the given callback instance to the current request that get invoked before given phase ID.
|
static void |
subscribeToRequestBeforePhase(PhaseId phaseId,
Callback.WithArgument<PhaseEvent> callback)
Subscribe the given callback instance to the current request that get invoked before given phase ID.
|
static void |
subscribeToViewAfterPhase(PhaseId phaseId,
Callback.Void callback)
Subscribe the given callback instance to the current view that get invoked every time after given phase ID.
|
static void |
subscribeToViewAfterPhase(PhaseId phaseId,
Callback.WithArgument<PhaseEvent> callback)
Subscribe the given callback instance to the current view that get invoked every time after given phase ID.
|
static void |
subscribeToViewBeforePhase(PhaseId phaseId,
Callback.Void callback)
Subscribe the given callback instance to the current view that get invoked every time before given phase ID.
|
static void |
subscribeToViewBeforePhase(PhaseId phaseId,
Callback.WithArgument<PhaseEvent> callback)
Subscribe the given callback instance to the current view that get invoked every time before given phase ID.
|
static void |
subscribeToViewEvent(Class<? extends SystemEvent> type,
Callback.Void callback)
Subscribe the given callback to the current view that get invoked every time when the given
system event type is published on the current view.
|
static void |
subscribeToViewEvent(Class<? extends SystemEvent> type,
Callback.WithArgument<SystemEvent> callback)
Subscribe the given callback to the current view that get invoked every time when the given
system event type is published on the current view.
|
static void |
subscribeToViewEvent(Class<? extends SystemEvent> type,
SystemEventListener listener)
Subscribe the given system event listener to the current view that get invoked every time when the given
system event type is published on the current view.
|
public static void subscribeToApplicationEvent(Class<? extends SystemEvent> type, SystemEventListener listener)
type
- The system event type to be observed.listener
- The system event listener to be subscribed.Application.subscribeToEvent(Class, SystemEventListener)
public static void subscribeToApplicationEvent(Class<? extends SystemEvent> type, Callback.Void callback)
type
- The system event type to be observed.callback
- The callback to be invoked.subscribeToApplicationEvent(Class, SystemEventListener)
public static void subscribeToApplicationEvent(Class<? extends SystemEvent> type, Callback.WithArgument<SystemEvent> callback)
type
- The system event type to be observed.callback
- The callback to be invoked.subscribeToApplicationEvent(Class, SystemEventListener)
public static void subscribeToViewEvent(Class<? extends SystemEvent> type, SystemEventListener listener)
type
- The system event type to be observed.listener
- The system event listener to be subscribed.UIViewRoot.subscribeToViewEvent(Class, SystemEventListener)
public static void subscribeToViewEvent(Class<? extends SystemEvent> type, Callback.Void callback)
type
- The system event type to be observed.callback
- The callback to be invoked.subscribeToViewEvent(Class, SystemEventListener)
public static void subscribeToViewEvent(Class<? extends SystemEvent> type, Callback.WithArgument<SystemEvent> callback)
type
- The system event type to be observed.callback
- The callback to be invoked.subscribeToViewEvent(Class, SystemEventListener)
public static void addViewPhaseListener(PhaseListener listener)
addRequestPhaseListener(PhaseListener)
is that the given phase listener is invoked
during every (postback) request on the same view instead of only during the current request.listener
- The phase listener to be added to the current view.UIViewRoot.addPhaseListener(PhaseListener)
public static void subscribeToViewBeforePhase(PhaseId phaseId, Callback.Void callback)
phaseId
- The phase ID to be observed.callback
- The callback to be invoked.addViewPhaseListener(PhaseListener)
public static void subscribeToViewBeforePhase(PhaseId phaseId, Callback.WithArgument<PhaseEvent> callback)
phaseId
- The phase ID to be observed.callback
- The callback to be invoked.addViewPhaseListener(PhaseListener)
public static void subscribeToViewAfterPhase(PhaseId phaseId, Callback.Void callback)
phaseId
- The phase ID to be observed.callback
- The callback to be invoked.addViewPhaseListener(PhaseListener)
public static void subscribeToViewAfterPhase(PhaseId phaseId, Callback.WithArgument<PhaseEvent> callback)
phaseId
- The phase ID to be observed.callback
- The callback to be invoked.addViewPhaseListener(PhaseListener)
public static void addRequestPhaseListener(PhaseListener listener)
addViewPhaseListener(PhaseListener)
is that the given phase listener is invoked
only during the current request instead of during every (postback) request on the same view.listener
- The phase listener to be added to the current request.CallbackPhaseListener
public static void subscribeToRequestBeforePhase(PhaseId phaseId, Callback.Void callback)
phaseId
- The phase ID to be observed.callback
- The callback to be invoked.addRequestPhaseListener(PhaseListener)
public static void subscribeToRequestBeforePhase(PhaseId phaseId, Callback.WithArgument<PhaseEvent> callback)
phaseId
- The phase ID to be observed.callback
- The callback to be invoked.addRequestPhaseListener(PhaseListener)
public static void subscribeToRequestAfterPhase(PhaseId phaseId, Callback.Void callback)
phaseId
- The phase ID to be observed.callback
- The callback to be invoked.addRequestPhaseListener(PhaseListener)
public static void subscribeToRequestAfterPhase(PhaseId phaseId, Callback.WithArgument<PhaseEvent> callback)
phaseId
- The phase ID to be observed.callback
- The callback to be invoked.addRequestPhaseListener(PhaseListener)
Copyright © 2012–2014 OmniFaces. All rights reserved.