Home Jsf Jsftraining Phase Listener



Phase Listener
Posted on: December 30, 2008 at 12:00 AM
JSF life-cycle includes six phases and phase events are fired during the start and end of each phase.

Phase Listener

        

JSF life-cycle includes six phases and phase events are fired during the start and end of each phase. We can capture phase events by defining a Phase Listener class as below. The class should implement PhaseListener interface. You can implement beforePhase() and afterPhase() methods according to the your need.

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;
   }
}

Download code for all examples

Related Tags for Phase Listener:
ceventsjsfeventincludeuritarincludesjsstartifcycleeachedeslifeliartinasstantjclesendasesstarincirhaphaseeaduandarrtssriringthstfelifndo


More Tutorials from this section

Ask Questions?    Discuss: Phase Listener  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.