Author: vkukharchuk
Date: 2007-07-16 09:03:29 -0400 (Mon, 16 Jul 2007)
New Revision: 1630
Added:
trunk/docs/ajaxguide/en/src/main/docbook/included/push.desc.xml
trunk/docs/ajaxguide/en/src/main/docbook/included/push.xml
Log:
http://jira.jboss.com/jira/browse/RF-438
Added: trunk/docs/ajaxguide/en/src/main/docbook/included/push.desc.xml
===================================================================
--- trunk/docs/ajaxguide/en/src/main/docbook/included/push.desc.xml
(rev 0)
+++ trunk/docs/ajaxguide/en/src/main/docbook/included/push.desc.xml 2007-07-16 13:03:29
UTC (rev 1630)
@@ -0,0 +1,9 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<root>
+<section>
+<title>Description</title>
+ <para>The <emphasis role="bold">
+ <property><a4j:push></property>
+ </emphasis>periodically perform AJAX request to server, to simulate
'push' data.</para>
+</section>
+</root>
\ No newline at end of file
Added: trunk/docs/ajaxguide/en/src/main/docbook/included/push.xml
===================================================================
--- trunk/docs/ajaxguide/en/src/main/docbook/included/push.xml
(rev 0)
+++ trunk/docs/ajaxguide/en/src/main/docbook/included/push.xml 2007-07-16 13:03:29 UTC
(rev 1630)
@@ -0,0 +1,85 @@
+<?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.components.Push</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>org.ajax4jsf.components.AjaxPush</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.components.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.ajax.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><a4j:push></property></emphasis>and
+ <emphasis
role="bold"><property><a4j:poll></property></emphasis>
components
+ is that <emphasis
role="bold"><property><a4j:push></property></emphasis>
makes request to minimal code only (not to JSF tree) in order to check the presence of
messages in the queue.
+ If the message exists the 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 user can set different value for
parameter 'timeout'.
+</para>
+Code for registration of listener:
+ <programlisting role="JAVA"><![CDATA[
+public void addListener(EventListener listener) {
+synchronized (listener) {
+ if (this.listener != listener) {
+ this.listener = (PushEventListener) listener;
+}
+]]></programlisting>
+
+
+Component can get message using current code:
+ <programlisting role="JAVA"><![CDATA[
+System.out.println("event occurs");
+synchronized (listener) {
+ listener.onEvent(new EventObject(this));
+}
+]]></programlisting>
+
+Thus, component 'push' uses asynchronous model instead of polls.
+
+ </section>
+</chapter>
\ No newline at end of file