JBoss.orgCommunity Documentation
The component adds an action listener to a parent component to provide possibility of Ajax update. It works like the <f:actionListener> or <f:valueChangeListener> JSF components but for the whole Ajax container.
The listener is invoked for Ajax requests only
The listener is always guaranteed to be invoked
Table 6.2. Component identification parameters
Name | Value |
---|---|
listener-class | org.ajax4jsf.event.AjaxListener |
event-class | org.ajax4jsf.event.AjaxEvent |
tag-class | org.ajax4jsf.taglib.html.jsp.AjaxListenerTag |
To create the simplest variant of the a4j:ajaxListener component on a page use the following syntax:
Example:
...
<a4j:ajaxListener type="demo.Bean"/>
...
Example:
package demo;
public class ImplBean implements import org.ajax4jsf.event.AjaxListener{
...
}
import demo.ImplBean;
...
ImplBean myListener = new ImplBean();
...
The <a4j:ajaxListener> component adds an action listener to a parent component, which needs to be provided with Ajax support. That listener is invoked on each Ajax request during the "Render Response" JSF phase. In comparison with JSF <f:actionListener> and <f:valueChangeListener> the invocation of the <a4j:ajaxListener> is not skipped in case when validation of Update Model fails. The <a4j:ajaxListener> is guarantied to be invoked for each Ajax response.
Ajax listener is not invoked for non-Ajax requests and when RichFaces works in the "Ajax Request generates Non-Ajax Response" mode.
As example of the <a4j:ajaxListener> component usage one can cite an updating the list of re-rendered components.
The
"type"
attribute defines the fully qualified Java class name for the listener.
This Java class implements
org.ajax4jsf.event.AjaxListener
interface, which is base interface for all listeners, capable for receiving Ajax events.
The source of the event could be accessed using the
java.util.EventObject.getSource()
call.
Example:
...
<a4j:commandLink id="cLink" value="Click it To Send Ajax Request">
<a4j:ajaxListener type="demo.Bean"/>
</a4j:commandLink>
...
Example:
package demo;
import org.ajax4jsf.event.AjaxEvent;
public class Bean implements org.ajax4jsf.event.AjaxListener{
...
public void processAjax(AjaxEvent arg){
//Custom Developer Code
}
...
}
Vizit AjaxListener page at RichFaces Livedemo for examples of component usage and their sources.
Check Sun JSF TLD documentation for more information on <f:valueChangeListener> tag.