previous | index | next

Interface Types for Listener Tags

Value Changes Actions
JSF Tag: f:valueChangeListener f:actionListener
Interface Type: ValueChangeListener ActionListener
Interface Method: processValueChange processAction

Q: Why use listener tags rather than attributes?

A: Can specify multiple listeners using tags:

     <h:commandButton image="mountrushmore.jpg" action="#{rushmore.navigate}">
        <f:actionListener type="com.corejsf.RushmoreListener"/>
        <f:actionListener type="com.corejsf.ActionLogger"/>
     </h:commandButton>

The first listener processes mouse events; the second logs action events.

When there are multiple listeners, their invocation order is:

  1. Any listener specified with the listener attribute,

  2. Any listeners specified by listener tags, in the order in which they are declared.

previous | index | next