<?xml version="1.0" encoding="UTF-8"?>
<section>
  <sectioninfo>
    <keywordset>
      <keyword>a4j:ajaxListener</keyword>
    </keywordset>
  </sectioninfo>
     <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.event.AjaxListener</entry>
          </row>
		  <row>
            <entry>event-class</entry>
            <entry>org.ajax4jsf.event.AjaxEvent</entry>
          </row>
          
          <row>
            <entry>tag-class</entry>
            <entry>org.ajax4jsf.taglib.html.jsp.AjaxListenerTag</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
	

  <section>
        <title>Creating the Component with a Page Tag</title>
    <para>To create the simplest variant of the <emphasis role="bold"><property>a4j:ajaxListener</property></emphasis> component 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.event.AjaxListener{
...
}
]]></programlisting>

	  <programlisting role="JAVA"><![CDATA[import demo.ImplBean;
...
ImplBean myListener = new ImplBean();
...]]></programlisting>
		
  </section>  
  
      <section>
            <title>Details of Usage</title>
            <para>The <emphasis role="bold"><property>&lt;a4j:ajaxListener&gt;</property></emphasis> 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 &quot;Render Response&quot; JSF phase. 
                  In comparison with JSF <emphasis role="bold"><property>&lt;f:actionListener&gt;</property></emphasis> and <emphasis role="bold"><property>&lt;f:valueChangeListener&gt;</property></emphasis> 
                  the invocation of the <emphasis role="bold"><property>&lt;a4j:ajaxListener&gt;</property></emphasis> is not skipped in case when validation of Update Model fails. 
                  The <emphasis role="bold"><property>&lt;a4j:ajaxListener&gt;</property></emphasis> is guarantied to be invoked for each Ajax response.
            </para>
                  
 <note>
       <para>
             Ajax listener is not invoked for non-Ajax requests and when RichFaces works in the &quot;Ajax Request generates Non-Ajax Response&quot; mode. 
       </para>
 </note>                 

<para>
      As example of the <emphasis role="bold"><property>&lt;a4j:ajaxListener&gt;</property></emphasis> component usage one can cite an updating the list of re-rendered components.
</para>

<para>
      The <emphasis><property>&quot;type&quot;</property></emphasis> attribute defines the fully qualified Java class name for the listener. 
      This Java class implements <code><ulink url="&apidoc_framework;/org/ajax4jsf/event/AjaxListener.html"><property>org.ajax4jsf.event.AjaxListener</property></ulink></code>interface, which is base interface for all listeners, capable for receiving Ajax events. 
      The source of the event could be accessed using the <code><ulink url="http://java.sun.com/j2se/1.4.2/docs/api/java/util/EventObject.html"><property>java.util.EventObject.getSource()</property></ulink></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.event.AjaxEvent;

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

  <section>
    <title>Relevant resources links</title>
      <para>
            Vizit <ulink url="http://livedemo.exadel.com/richfaces-demo/richfaces/ajaxListener.jsf?c=ajaxListener">AjaxListener</ulink> page at RichFaces Livedemo for examples of component usage and their sources. 
      </para>
        <para>
              Check Sun JSF TLD documentation for more information on <ulink url="http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/tlddocs/f/valueChangeListener.html">&lt;f:valueChangeListener&gt; tag</ulink>. 
        </para>
  </section>
</section>