HTML and CSS Reference
In-Depth Information
Listing 4-19. Defining the Phase Listener in the Faces Configuration File
<faces-config ...>
...
<lifecycle>
<phase-listener>
com.jsfprohtml5.firstapplication.model.AuthorizationListener
</phase-listener>
</lifecycle>
</faces-config>
If you want to apply a phase listener on a specific view instead of applying it on all the pages, you can do
this by using the <f:phaseListener> tag as follows: <f:phaseListener type="package.CustomPhaseListener">
(where type attribute represents the fully qualified phase listener Java class name to be created and registered).
<f:phaseListener> tag registers a PhaseListener instance on the UIViewRoot in which this tag is nested.
Tip
System Events
System events are introduced in JSF 2.0 to allow the JSF developer to listen for and to react to advanced life cycle
events. As illustrated earlier in the chapter, System events can occur on the JSF application level (like application
startup or application teardown) or on the JSF component level. Unlike Faces events, System events are published
immediately, which means that they are not queued to later life cycle processing phases. Table 4-2 shows the different
types of System events that can occur on the application level (directly extends SystemEvent ).
Table 4-2. JSF System Events on the Application Level (Extends SystemEvent)
System Event
Description
PostConstructApplicationEvent
Published immediately once the application startup completes.
PreDestroyApplicationEvent
Published immediately before the application shutdowns.
ExceptionQueuedEvent
Published when an unexpected exception in the JSF application is thrown.
This can happen at any of the JSF life cycle processing phases.
System events can also occur on the component level. Table 4-3 shows the most common types of System events
that can occur on the component level. All of the following events extend from ComponentSystemEvent .
 
 
Search WWH ::




Custom Search