<?xml version='1.0' encoding='UTF-8'?>
<chapter>
  
      <table>
      <title>Component identification parameters </title>
      <tgroup cols="2">
        <thead>
          <row>
            <entry>Name</entry>
            <entry>Value</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>component-type</entry>
            <entry>org.ajax4jsf.Push</entry>
          </row>
          <row>
            <entry>component-family</entry>
            <entry>org.ajax4jsf.components.AjaxPush</entry>
          </row>
          <row>
            <entry>component-class</entry>
            <entry>org.ajax4jsf.component.html.AjaxPush</entry>
          </row>
          <row>
            <entry>renderer-type</entry>
            <entry>org.ajax4jsf.components.AjaxPushRenderer</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
  
  <section>
    <title>Creating on a page</title>
    <programlisting role="XML"><![CDATA[
<a4j:push reRender="msg" eventProducer="#{messageBean.addListener}" interval="3000"/>]]></programlisting>
  </section>
 
 <section>
    <title>Dynamical creation of a component from Java code</title>
   <programlisting role="JAVA"><![CDATA[import org.ajax4jsf.component.html.AjaxPush;
...
AjaxPush myPush = new AjaxPush();
...]]></programlisting>
  </section>
  
  <section>
    <title>Key attributes and ways of usage</title>
	<para>The main difference between <emphasis role="bold"><property>&lt;a4j:push&gt;</property></emphasis>and
	<emphasis role="bold"><property>&lt;a4j:poll&gt;</property></emphasis> components
	is that <emphasis role="bold"><property>&lt;a4j:push&gt;</property></emphasis> makes request to minimal code only (not to JSF tree) in order to check the presence of messages in the queue. 
	If a message exists, a complete request will be performed.
	The component doesn't poll registered beans but registers EventListener which receives messages about events.
	</para>	
<para>
	There are some attributes which allows to customize of the component behaviour:
</para>
<para>
'interval' - Interval (in ms) for call push requests. Default value 1000 (1 sec).
<!-- If "0" a connection is permanent. Also you can set different value for parameter 'timeout'. -->
</para>
<para>
Code for registration of listener:
</para>
    <programlisting role="JAVA"><![CDATA[
public void addListener(EventListener listener) {
synchronized (listener) {
	if (this.listener != listener) {
	this.listener = (PushEventListener) listener;
}
]]></programlisting>
   
<para>   
Component can get message using current code:
</para>
    <programlisting role="JAVA"><![CDATA[
System.out.println("event occurs");
synchronized (listener) {
	listener.onEvent(new EventObject(this));
}
]]></programlisting>
<para>
Thus, component 'push' uses asynchronous model instead of polls.
</para>
  </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/push.jsf?c=push">here.
	</ulink>
	</para>
  </section> -->
</chapter>