Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jsf Jsftraining Phase Listener

Related Tutorials


 
 

Share on Google+Share on Google+

Phase Listener

Advertisement
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

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 30, 2008

Related Tutorials

Discuss: Phase Listener  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
Ram
June 21, 2011
403 error

Hi When i ran this application, getting 403. I pointed welcome file to login.jsp then also its giving the same error. Any idea what's going wrong here. Thanks Ram
DMCA.com