HTML and CSS Reference
In-Depth Information
Figure 4-2.
JSF event listeners
There are two types of JSF event listeners:
•
Faces Listener
is the base interface for action listener, value change listener, System event
listener, and component System event listener.
•
Phase Listener
is the listener interface for the beginning and ending of each standard phase
of the JSF request processing lifecycle.
Let's go into the details of the child listeners to understand who can create these listeners and when they can be
executed. Figure
4-3
shows the two types of application-related event listeners:
•
ActionListener
interface, which is responsible for receiving action events.
•
ValueChangeListener
interface, which is responsible for receiving value change events.
Figure 4-3.
Application-related event listeners
As shown in this figure,
ActionSource
component (or
ActionSource2
component) may have more than one or
more action listener(s).
EditableValueHolder
component (such as
UIInput
component) or
ValueHolder
component
may have one or more value change listener(s).
System event listeners, by definition, listen for System events. System events, which were introduced in JSF 2.0,
provide an elegant view on the JSF life cycle. Using System event listeners, the JSF developer can, for example, write
custom code that will be executed in the application startup and teardown events or be executed when an exception is
thrown in the application.
SystemEventListener
is the main interface for System event listeners.
SystemEventListener
can listen for
all
SystemEvents
types.
System events
can be triggered on the JSF application level (like application startup or
application teardown or application exception) or on the JSF component level (like “before validating the component”
or “after validating the component” or “before the view is rendered”). If System events occur on the component level,
then in this case you may use the more specific event listener, which is
ComponentSystemEventListener
interface
(shown in Figure
4-2
) to handle. This is because
ComponentSystemEventListener
listens for
ComponentSystemEvent
(which extends
SystemEvent
).
