O'Reilly logo

JavaServer Faces by Hans Bergsten

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Capturing State with a PhaseListener

An interesting use of the PhaseListener class we discussed in the previous section is to capture data about the request and all components in each phase and save the data where it can be picked up and displayed later. The captured data can be used to better understand what happens in the different phases and to figure out why things don’t work as expected.

I developed a PhaseListener that captures most data of interest, including the component tree structure, all component attributes and properties, and all variables in the request, session and application scopes, before and after each phase. Figure 12-8 shows an example of a response rendered by a servlet where you can analyze the captured data.

Analyzing captured data
Figure 12-8. Analyzing captured data

The data is displayed as a tree. The first level of the tree has one node for each point in the lifecycle. For each such node, there’s a node that holds the component tree and another that holds the scoped variables. You can compare a component’s property values in different phases and see when they change. For instance, if you look at an input component, you see how the submitted value migrates from the submittedValue property to the localValue and value properties.

I’ve commented out the registration elements for this listener in the example application’s faces-config.file because there’s a fair amount of processing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required