org.omnifaces.eventlistener
Class CallbackPhaseListener

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

public class CallbackPhaseListener
extends java.lang.Object
implements javax.faces.event.PhaseListener

This phase listener picks up phase listener instances from the request scope by addCallbackXxx() methods of the Events utility class and calls them back for each matching phase.

This differs in a few subtle ways from Events.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 removed manually (in Mojarra this can be difficult due to the fact iterators over listeners are kept 'open' during each phase).

Since:
1.2
Author:
Arjan Tijms, Bauke Scholtz
See Also:
Events.addCallbackPhaseListener(PhaseListener), Events.addCallbackBeforePhaseListener(PhaseId, org.omnifaces.util.Callback.Void), Events.addCallbackAfterPhaseListener(PhaseId, org.omnifaces.util.Callback.Void), Serialized Form

Constructor Summary
CallbackPhaseListener()
           
 
Method Summary
static void add(javax.faces.event.PhaseListener phaseListener)
           
 void afterPhase(javax.faces.event.PhaseEvent event)
           
 void beforePhase(javax.faces.event.PhaseEvent event)
           
 javax.faces.event.PhaseId getPhaseId()
           
static boolean remove(javax.faces.event.PhaseListener phaseListener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CallbackPhaseListener

public CallbackPhaseListener()
Method Detail

getPhaseId

public javax.faces.event.PhaseId getPhaseId()
Specified by:
getPhaseId in interface javax.faces.event.PhaseListener

beforePhase

public void beforePhase(javax.faces.event.PhaseEvent event)
Specified by:
beforePhase in interface javax.faces.event.PhaseListener

afterPhase

public void afterPhase(javax.faces.event.PhaseEvent event)
Specified by:
afterPhase in interface javax.faces.event.PhaseListener

add

public static void add(javax.faces.event.PhaseListener phaseListener)
See Also:
Events.addCallbackPhaseListener(PhaseListener)

remove

public static boolean remove(javax.faces.event.PhaseListener phaseListener)
See Also:
Events.removeCallbackPhaseListener(PhaseListener)