### 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. < a4j:ajaxListener >

### 6.1.1. Description

The <a4j:ajaxListener> component is the same one as <f:actionListener> or <f:valueChangeListener> , but for an Ajax container.

Table 6.1. a4j : ajaxListener attributes

Attribute Name | Description
--- | ---
type | Fully qualified Java class name of an AjaxListener to be created and registered.

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

### 6.1.2. Creating on a page

To create the simplest variant on a page use the following syntax:

Example:

    ...

        <a4j:ajaxListener type="demo.Bean"/>

    ...

### 6.1.3. Creating the Component Dynamically Using Java

Example:

    package demo;

    public class ImplBean implements import org.ajax4jsf.event.AjaxListener{

        ...

    }

    import demo.ImplBean;

    ...

    ImplBean myListener = new ImplBean();

    ...

### 6.1.4. Key attributes and ways of usage

Additional to the listeners provided by JSF specification, RichFaces add one more: ajax Listener ( <a4j:ajaxListener> ). Ajax Listener is invoked before the Render Response phase. Instead of <f:actionListener> of <f:valueChangeListener> which are not invoked when Validation of Update Model phases failed, ajax Listener is guarantied to be invoked for each Ajax response. Thus, it is a good place for update the list of re-rendered components, for example. Ajax Listener is not invoked for non-Ajax request and when RichFaces works in "Ajax Request generates Non-Ajax Response" mode. Therefore, ajax Listener invocation is a good indicator that Ajax response is going to be processed. Attribute "type" described in the following chapter. It defines the fully qualified Java class name for listener. This class implements `org.ajax4jsf.event.AjaxListener` interface. You can access to the source of the event (Ajax component) using `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

        }

    ...

    }

### 6.1.5. Relevant resources links

Some additional information about usage of component can be found on RichFaces Live Demo page.

More information about <f:valueChangeListener> can be found in Sun JSF TLD documentation .

- PrevChapter 6. The RichFaces Components
- Top of page
- Front page
- Next6.2. < a4j:keepAlive >