<?xml version="1.0" encoding="UTF-8"?>
<chapter>
  <chapterinfo>
    <keywordset>
      <keyword>a4j:ajaxListener</keyword>
    </keywordset>
  </chapterinfo>
     <table>
	  <title>Component identification parameters </title>
      <tgroup cols="2">
	  <thead>
            <row>
                  <entry>Name</entry>
                  <entry>Value</entry>
            </row>
        </thead>
        <tbody>
		
          <row>
            <entry>listener-class</entry>
            <entry>org.ajax4jsf.framework.ajax.AjaxListener</entry>
          </row>
		  <row>
            <entry>event-class</entry>
            <entry>org.ajax4jsf.framework.ajax.AjaxEvent</entry>
          </row>
          
          <row>
            <entry>tag-class</entry>
            <entry>org.ajax4jsf.taglib.html.jsp.AjaxListenerTag</entry>
          </row>
		  
        </tbody>
      </tgroup>
    </table>
	

  <section>
    <title>Creating on a page</title>
    <para>To create the simplest variant on a page use the following syntax:</para>

  <para>
      <emphasis role="bold">Example:</emphasis>
 </para>

	<programlisting role="XML"><![CDATA[...
	<a4j:ajaxListener type="demo.Bean"/>
...
]]></programlisting> 
  </section>
 
  <section>
    <title>Creating the Component Dynamically Using Java</title>
	  <para>
		  <emphasis role="bold">Example:</emphasis></para>		
	  <programlisting role="JAVA"><![CDATA[package demo;
	  
public class ImplBean implements import org.ajax4jsf.component.html.AjaxListener{
	...
}
]]></programlisting>

	  <programlisting role="JAVA"><![CDATA[
import demo.ImplBean;
...
ImplBean myListener = new ImplBean();
...
]]></programlisting>
		
  </section>  
  
  <section>
    <title>Key attributes and ways of usage</title>
	<para>
Additional to the listeners provided by JSF specification, RichFaces add one more: ajax Listener (
	<emphasis role="bold"><property>&lt;a4j:ajaxListener&gt;</property>
	</emphasis>).
	  Ajax Listener is invoked before the Render Response phase. Instead of <emphasis role="bold"><property>&lt;f:actionListener&gt;</property></emphasis> of <emphasis role="bold"><property>&lt;f:valueChangeListener&gt;</property></emphasis> 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 <emphasis><property>&quot;type&quot;</property></emphasis> described in the following  <link linkend="ajaxListener"> chapter</link>. It defines the fully qualified Java class name for listener. This class implements <code>org.ajax4jsf.framework.ajax.ajaxListener</code>
	  <ulink url="http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone/docs/apidoc_framework/index.html">interface</ulink>. You can access to the source of the event (Ajax component) using <code>event.getSource()</code> call. 
	</para>
 
  <para>
      <emphasis role="bold">Example:</emphasis>
 </para>

    <programlisting role="XML"><![CDATA[...
	<a4j:commandLink id="cLink" value="Click it To Send Ajax Request">
		<a4j:ajaxListener type="demo.Bean"/>
	</a4j:commandLink>
...
]]></programlisting> 

<para>
      <emphasis role="bold">Example:</emphasis>
 </para>

    <programlisting role="JAVA"><![CDATA[package demo;

import org.ajax4jsf.framework.ajax.AjaxEvent;

public class Bean implements org.ajax4jsf.framework.ajax.AjaxListener{
...	
	public void processAjax(AjaxEvent arg0){
		//Custom Developer Code 
	}
...
}
]]></programlisting> 
  </section>  

  <section>
    <title>Relevant resources links</title>
	<para>
	  Some additional information about usage of component can be found 
	  <ulink url="http://livedemo.exadel.com/richfaces-demo/richfaces/ajaxListener.jsf?c=ajaxListener">here</ulink>.</para>
    <para>
      More information about <emphasis role="bold"><property>&lt;f:valueChangeListener&gt;</property></emphasis> can be found <ulink url=" http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/tlddocs/f/valueChangeListener.html">here</ulink>. 
	</para>
  </section>
  
</chapter>