As we are aware that the Request processing life-cycle in JSF includes six phases and any JSF implementation will fire Phase Events during the start and end of each phase. If we want to capture the Phase Events, then can define a Phase Listener class as follows.


package roseindia.phaselistener;

import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;

public class CustomPhaseListener implements PhaseListener

public CustomPhaseListener()
{
}

public void afterPhase(PhaseEvent event)
{
System.out.println("After Phase: " + event.getPhaseId()); 
}

public void beforePhase(PhaseEvent event)
{
System.out.println("Before Phase: " + event.getPhaseId());
}

public PhaseId getPhaseId()
{
return PhaseId.ANY_PHASE;

}