HTML and CSS Reference
In-Depth Information
Table 4-3. JSF System Events on the Component Level (Extends ComponentSystemEvent)
System Event
Description
PreRenderComponentEvent
This event is published just before the rendering of the component.
PostAddToViewEvent
This event is published just after the component is added to the JSF view.
PreValidateEvent
This event is published just before the component is about to be validated.
PostValidateEvent
This event is published just after the component is validated.
PreDestroyViewMapEvent
This event is published just before the view scope map is about to be destroyed.
PostConstructViewMapEvent
This event is published just after the view scope map is created.
PreRenderViewEvent
This event is published just before the view ( UIViewRoot ) is about to be rendered.
PostRestoreStateEvent
This event is published just after the component state is restored.
In order to see how we can use System events in order to empower our JSF applications, let's get back to the
subscriber application which we created in Chapter 3. Assume that we want to introduce a new drop-down item that
will include list of professions, as shown in Figure 4-8 . The list of professions is static in the application, so it will be
loaded once when the application starts and will be unloaded before the application shuts down.
Figure 4-8. The updated subscriber application screen
In order to implement this functionality, we can use PostConstructApplicationEvent to load the static
listing data just after the application starts and PreDestroyApplicationEvent to make any cleanup just before the
application shutdowns.
Listing 4-20 shows our application's custom SystemEvent listener, which will be called just after the application
starts and just before the application shuts down.
Listing 4-20. Subscriber Custom SystemEvent Listener
package com.jsfprohtml5.subscriber.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.faces.application.Application;
 
 
Search WWH ::




Custom Search