### Create new RichFaces Documentation Jira issue

Summary
255 characters left
Description
Environment
This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.org Community Documentation

- Prev
- Next

### 6.1.1. < a4j:ajaxListener > available since 3.0.0

expand all

#### 6.1.1.1. Description

The <a4j:ajaxListener> component adds an action listener to a parent component and works like the <f:actionListener> or <f:valueChangeListener> JSF components but for the whole Ajax container.

#### 6.1.1.2. Details of Usage

The <a4j:ajaxListener> component adds an action listener to a parent component. That listener is invoked on each Ajax request during the "Render Response" JSF phase. In comparison with standard JSF <f:actionListener> and <f:valueChangeListener> components 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.

The "type" attribute defines the fully qualified Java class name for the listener. This Java class should implement `org.ajax4jsf.event.AjaxListener` interface which is base interface for all listeners, capable for receiving Ajax events. The object on which the Event initially occurred could be accessed using the `java.util.EventObject.getSource()` method.

The <a4j:ajaxListener> is not invoked for non-Ajax requests and when RichFaces works in the "Ajax Request generates Non-Ajax Response" mode, so <a4j:ajaxListener> invocation is a good indicator that Ajax Response is going to be processed. Let's check it in the following example.

Example:

    ...

    <rich:messages/>

    <h:form id="form">

        <a4j:commandLink value="Click to send Ajax request">

            <a4j:ajaxListener type="org.docs.richfaces.actionListenerBean"/>

        </a4j:commandLink>

    </h:form>

    ...

Example:

    ...

    public class ActionListenerBean implements org.ajax4jsf.event.AjaxListener {

        public void processAjax(AjaxEvent event) {

            FacesContext.getCurrentInstance().addMessage("form", new FacesMessage("Ajax request is sent"));

        }

    }

    ...

There is a result:

Figure 6.1. Usage of the <a4j:ajaxListener>

#### 6.1.1.3. Reference Data

Table of <a4j:ajaxListener> attributes.

Table 6.1. 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

#### 6.1.1.4. Relevant Resources Links

Visit 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.

- Prev6.1. Ajax Support
- Top of page
- Front page
- Next6.1.2. < a4j:actionparam ...