Book Image

Mastering JavaServer Faces 2.2

By : Anghel Leonard
Book Image

Mastering JavaServer Faces 2.2

By: Anghel Leonard

Overview of this book

Table of Contents (20 chapters)
Mastering JavaServer Faces 2.2
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The JSF Life Cycle
Index

Configuring phase listeners


As the name suggests, a phase listener is capable to listen to the start and end of each of the six JSF life-cycle phases (a detailed diagram of how JSF phases interact with each other is available in Appendix, The JSF Life Cycle):

  • Restore the View phase

  • Apply the Request Values phase

  • Process the Validations phase

  • Update the Model Values phase

  • Invoke the Application phase

  • Render the Response phase

You can easily capture the events of each phase by following these three steps:

  1. Implementing the PhaseListener interface.

  2. Overriding the afterPhase, beforePhase, and getPhaseId methods.

  3. Configuring the phase listener in faces-config.xml.

A good point to start is a simple but useful PhaseListener that can be used to debug the phases. If you ever had the curiosity to see what is happening in JSF request lifecycle, then you can use this phase listener, which is defined as follows:

public class DebugPhaseListener implements PhaseListener {

    public DebugPhaseListener() {
    }

...