Tag Archives: JSF - Page 2

JSF Phase Listeners – Important Points (Short Notes on What When How )

What is JSF Phase Listener?

A Phase Listener is a class that simply implements javax.faces.event.PhaseListener
and registers itself with the JSF implementation and will be invoked before and after each phase
in the JSF lifecycle that the implemented phase listener wants to be notified about

jsf

jsf

How to Define JSF Phase Listener?
It’s a simply two step process

  •      Write a java class that simply implements javax.faces.event.PhaseListener
  •      Registering it with Java Server Faces in faces-config xml file

     We can implement multiple phase listeners and register in faces config xml file and the order of registration of listeners determines the order in which these listeners will be called during the JSF lifecycle

When to Use?
JSF Phase Listeners can be used to Add Custom processing logic into the JSF lifecycle.
Phase listeners can be used as a perful debugging tool
We can register a listener with the JSF implementation
and the implementation will then notify our listener at both before and after the phase
that our listener is interested in.

Other Notes;
JSF guarantees that if a listener’s beforePhase() method completes successfully,
then its afterPhase() will also be called as normal even if a subsequent listener beforePhase()
method throws an exception. Also important thing to remember is that the JSF Listeners will add
overhead to the JSF lifecycle process and it’s important that we use as appropriate.


Java Server Faces ( JSF 1.0 / JSF 1.1 / JSF 1.1_01 / JSF 1.2 / JSF2.0 ) Comparision Table

Version JSR Release What’s on the release? Support Release Date Additional Info
JSF 1.0 JSR 127 Initial release of the JSF specification. Separate release that wasn’t part of any Java EE/J2EE release. Servlet 2.3 and
JSP 1.2
11/03/2004 DEPRECATED
JSF 1.1 JSR 127 just bug fixes released and no changes to rendering HTML kit Servlet 2.3 and
JSP 1.2
02/05/2004 DEPRECATED
JSF 1.1_01 bug fixes and performance improvements. JDK 1.3.1 or later.
JSF 1.2 JSR 252 Many improvements to core systems and APIs. Coincides with Java EE 5. Initial adoption into Java EE. Servlet 2.5 and JSP 2.1
But minimum it supports Servlet 2.3 and JSP 1.2.
Tomcat support 6.0 not 5.5.version
11/05/2006
JSF 2.0 Major release for ease of use, enhanced functionality, and performance. Coincides with Java EE 6. 28/06/2009
JSF 2.1 Current version. Second maintenance release of 2.0. Only very minor amount of spec changes 22/10/2010