Author: alexsmirnov
Date: 2007-05-03 21:10:03 -0400 (Thu, 03 May 2007)
New Revision: 168
Added:
tags/1_1_1_rc1/
tags/1_1_1_rc1/docs/resources/
tags/1_1_1_rc1/docs/userguide/en/included/commandButton.xml
tags/1_1_1_rc1/docs/userguide/en/included/commandlink.xml
tags/1_1_1_rc1/docs/userguide/en/included/form.xml
tags/1_1_1_rc1/docs/userguide/en/included/htmlCommandLink.xml
tags/1_1_1_rc1/docs/userguide/en/included/include.xml
tags/1_1_1_rc1/docs/userguide/en/included/jsFunction.xml
tags/1_1_1_rc1/docs/userguide/en/included/loadScript.xml
tags/1_1_1_rc1/docs/userguide/en/included/log.xml
tags/1_1_1_rc1/docs/userguide/en/included/mediaOutput.xml
tags/1_1_1_rc1/docs/userguide/en/included/outputPanel.xml
tags/1_1_1_rc1/docs/userguide/en/included/page.xml
tags/1_1_1_rc1/docs/userguide/en/included/poll.xml
tags/1_1_1_rc1/docs/userguide/en/included/region.xml
tags/1_1_1_rc1/docs/userguide/en/included/repeat.xml
tags/1_1_1_rc1/docs/userguide/en/included/status.xml
tags/1_1_1_rc1/docs/userguide/en/included/support.xml
tags/1_1_1_rc1/docs/userguide/en/master.xml
tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGfaq.xml
tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGstart.xml
tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGusingAJAX.xml
tags/1_1_1_rc1/framework/pom.xml
tags/1_1_1_rc1/framework/src/main/config/component/push.xml
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/PushEventListener.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIPush.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/ComponentInvoker.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/JsfOneOneInvoker.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/PollEventsManager.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
tags/1_1_1_rc1/framework/src/main/javascript/ajaxjsf/JSFAJAX.js
tags/1_1_1_rc1/samples/seamIntegration/.exadelproject
tags/1_1_1_rc1/samples/useCases/src/main/java/control/
tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/A4jTestBean.java
tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/Bean.java
tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/MessageBean.java
tags/1_1_1_rc1/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml
tags/1_1_1_rc1/samples/useCases/src/main/webapp/css/
tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/actionparam.xhtml
tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/ajaxSingle.xhtml
tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/controls.jsp
tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/controls.xhtml
tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/push.xhtml
Removed:
tags/1_1_1_rc1/docs/resources/
tags/1_1_1_rc1/docs/userguide/en/included/commandButton.xml
tags/1_1_1_rc1/docs/userguide/en/included/commandlink.xml
tags/1_1_1_rc1/docs/userguide/en/included/form.xml
tags/1_1_1_rc1/docs/userguide/en/included/htmlCommandLink.xml
tags/1_1_1_rc1/docs/userguide/en/included/include.xml
tags/1_1_1_rc1/docs/userguide/en/included/jsFunction.xml
tags/1_1_1_rc1/docs/userguide/en/included/loadScript.xml
tags/1_1_1_rc1/docs/userguide/en/included/log.xml
tags/1_1_1_rc1/docs/userguide/en/included/mediaOutput.xml
tags/1_1_1_rc1/docs/userguide/en/included/outputPanel.xml
tags/1_1_1_rc1/docs/userguide/en/included/page.xml
tags/1_1_1_rc1/docs/userguide/en/included/poll.xml
tags/1_1_1_rc1/docs/userguide/en/included/region.xml
tags/1_1_1_rc1/docs/userguide/en/included/repeat.xml
tags/1_1_1_rc1/docs/userguide/en/included/status.xml
tags/1_1_1_rc1/docs/userguide/en/included/support.xml
tags/1_1_1_rc1/docs/userguide/en/master.xml
tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGfaq.xml
tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGstart.xml
tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGusingAJAX.xml
tags/1_1_1_rc1/framework/pom.xml
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/ComponentInvoker.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/JsfOneOneInvoker.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
tags/1_1_1_rc1/framework/src/main/javascript/ajaxjsf/JSFAJAX.js
tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/Bean.java
tags/1_1_1_rc1/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml
Log:
Copied: tags/1_1_1_rc1 (from rev 158, trunk)
Copied: tags/1_1_1_rc1/docs/resources (from rev 163, trunk/docs/resources)
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/commandButton.xml
===================================================================
--- trunk/docs/userguide/en/included/commandButton.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/commandButton.xml 2007-05-04 01:10:03 UTC
(rev 168)
@@ -1,61 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <para><table frame="all">
- <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.ajax.CommandButton</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>javax.faces.Command </entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.HtmlCommandButton</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.components.AjaxCommandButtonRenderer
</entry>
- </row>
- </tbody>
- </tgroup>
- </table></para>
- </section>
- <section>
- <title>Creating on a page</title>
- <para><emphasis
role="bold"><property><a4j:commandButton></property></emphasis>
is used in the same way as <emphasis
role="bold"><property><h:commandButton></property></emphasis>,
but with definition of the area that is updated after the response comes back from the
server.</para>
- <programlisting role="XML"><![CDATA[<a4j:commandButton
reRender="someData" action="#bean.action1"
value="Link"/>]]></programlisting>
- <para>This definition of the component provides a link, a click on the
link causes an AJAX form submit on the server, "action1" method
performance, and rendering of the component with "someData" id after the
response comes back from the server.</para>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxCommandButton;
-...
-HtmlAjaxCommandButton myButton = new org.ajax4jsf.ajax.html.HtmlAjaxCommandButton();
-...
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>The component <emphasis
role="bold"><property><a4j:commandButton></property></emphasis>
placed on a page generates the following HTML code:</para>
- <programlisting role="XHTML"><![CDATA[<input
type="submit" onclick="A4J.AJAX.Submit(...request parameters);return
false;" value="sort"/>
-]]></programlisting>
- <para>Hence, the utility method "A4J.AJAX.Submit" is called
on a click, the method performs AJAX request as the <emphasis
role="bold"><property><a4j:support></property></emphasis>
component</para>
- <note>
- <title>Note:</title>
- <para>AJAX support is built in and it's not necessary to add nested
<emphasis
role="bold"><property><a4j:support></property></emphasis>
to the component.</para>
- </note>
- <para>Common JSF navigation could be performed after AJAX submit and partial
rendering, but Navigation Case must be defined as <emphasis
role="bold"><property><redirect/></property></emphasis>
in order to avoid problems with some browsers.</para>
- <para>As any Ajax4jsf component sending AJAX requests and processing server
responses <emphasis
role="bold"><property><a4j:commandButton></property></emphasis>
has all attributes described above (see <emphasis
role="bold"><property><a4j:support></property></emphasis>
chapter) that provide the required behavior of requests sending (delay, limitation of
submit area and rendering, and etc.)</para>
- </section>
-</chapter>
\ No newline at end of file
Copied: tags/1_1_1_rc1/docs/userguide/en/included/commandButton.xml (from rev 163,
trunk/docs/userguide/en/included/commandButton.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/commandButton.xml
(rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/commandButton.xml 2007-05-04 01:10:03 UTC
(rev 168)
@@ -0,0 +1,61 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <para><table frame="all">
+ <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.ajax.CommandButton</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>javax.faces.Command </entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.HtmlCommandButton</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.components.AjaxCommandButtonRenderer
</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para><emphasis
role="bold"><property><a4j:commandButton></property></emphasis>
is used in the same way as <emphasis
role="bold"><property><h:commandButton></property></emphasis>,
but with definition of the area that is updated after the response comes back from the
server.</para>
+ <programlisting role="XML"><![CDATA[<a4j:commandButton
reRender="someData" action="#{bean.action1}"
value="Link"/>]]></programlisting>
+ <para>This definition of the component provides a link, a click on the
link causes an AJAX form submit on the server, "action1" method
performance, and rendering of the component with "someData" id after the
response comes back from the server.</para>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxCommandButton;
+...
+HtmlAjaxCommandButton myButton = new HtmlAjaxCommandButton();
+...
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>The component <emphasis
role="bold"><property><a4j:commandButton></property></emphasis>
placed on a page generates the following HTML code:</para>
+ <programlisting role="XHTML"><![CDATA[<input
type="submit" onclick="A4J.AJAX.Submit(...request parameters);return
false;" value="sort"/>
+]]></programlisting>
+ <para>Hence, the utility method "A4J.AJAX.Submit" is called
on a click, the method performs AJAX request as the <emphasis
role="bold"><property><a4j:support></property></emphasis>
component</para>
+ <note>
+ <title>Note:</title>
+ <para>AJAX support is built in and it's not necessary to add nested
<emphasis
role="bold"><property><a4j:support></property></emphasis>
to the component.</para>
+ </note>
+ <para>Common JSF navigation could be performed after AJAX submit and partial
rendering, but Navigation Case must be defined as <emphasis
role="bold"><property><redirect/></property></emphasis>
in order to avoid problems with some browsers.</para>
+ <para>As any Ajax4jsf component sending AJAX requests and processing server
responses <emphasis
role="bold"><property><a4j:commandButton></property></emphasis>
has all attributes described above (see <emphasis
role="bold"><property><a4j:support></property></emphasis>
chapter) that provide the required behavior of requests sending (delay, limitation of
submit area and rendering, and etc.)</para>
+ </section>
+</chapter>
\ No newline at end of file
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/commandlink.xml
===================================================================
--- trunk/docs/userguide/en/included/commandlink.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/commandlink.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,68 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <para><table frame="all">
- <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.ajax.CommandLink</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>javax.faces.Command </entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.HtmlCommandLink</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.components.AjaxCommandLinkRenderer
</entry>
- </row>
- </tbody>
- </tgroup>
- </table></para>
- </section>
- <section>
- <title>Creating on a page</title>
- <para><emphasis
role="bold"><property><a4j:commandLink></property></emphasis>
is used in the same way as <emphasis
role="bold"><property><h:commandLink></property></emphasis>,
but with definition of the area that is updated after the response comes back from the
server.</para>
- <programlisting role="XML"><![CDATA[<a4j:commandLink
reRender="someData" action="#bean.action1"
value="Link"/>]]></programlisting>
- <para>This definition of the component provides a link, a click on the
link causes an AJAX form
- submit on the server, "action1" method performance, and
rendering of the component
- with "someData" id after the response comes back from the
server.</para>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxCommandLink;
-...
-HtmlAjaxCommandLink myLink = new org.ajax4jsf.ajax.html.HtmlAjaxCommandLink();
-...
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>The component <emphasis
role="bold"><property><a4j:commandLink></property></emphasis>
placed on a page generates the following HTML code:</para>
- <programlisting role="JSP"><![CDATA[<a href="#"
onclick="A4J.AJAX.Submit(?"request parameters");
- return
- <a href="#" onclick="A4J.AJAX.Submit(?"request
parameters");
- return false;">
- <span style="color: black;">Link Value</span>
- </a>
-]]></programlisting>
- <para>Hence, the utility method "A4J.AJAX.Submit" is called
on a click, the method performs AJAX request as the <emphasis
role="bold"><property><a4j:support></property></emphasis>
component</para>
- <note>
- <title>Note:</title>
- <para>AJAX support is built in and it's not necessary to add nested
<emphasis
role="bold"><property><a4j:support></property></emphasis>
to the component.</para>
- </note>
- <para>Common JSF navigation could be performed after AJAX submit and partial
rendering, but Navigation Case must be defined as <emphasis
role="bold"><property><redirect/></property></emphasis>
in order to avoid problems with some browsers.</para>
- <para>As any Ajax4jsf component sending AJAX requests and processing server
responses <emphasis
role="bold"><property><a4j:commandLink></property></emphasis>
has all attributes described above (see <emphasis
role="bold"><property><a4j:support></property></emphasis>
chapter) that provide the required behavior of requests sending (delay, limitation of
submit area and rendering, etc.)</para>
- </section>
-</chapter>
\ No newline at end of file
Copied: tags/1_1_1_rc1/docs/userguide/en/included/commandlink.xml (from rev 163,
trunk/docs/userguide/en/included/commandlink.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/commandlink.xml (rev
0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/commandlink.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,68 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <para><table frame="all">
+ <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.ajax.CommandLink</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>javax.faces.Command </entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.HtmlCommandLink</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.components.AjaxCommandLinkRenderer
</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para><emphasis
role="bold"><property><a4j:commandLink></property></emphasis>
is used in the same way as <emphasis
role="bold"><property><h:commandLink></property></emphasis>,
but with definition of the area that is updated after the response comes back from the
server.</para>
+ <programlisting role="XML"><![CDATA[<a4j:commandLink
reRender="someData" action="#{bean.action1}"
value="Link"/>]]></programlisting>
+ <para>This definition of the component provides a link, a click on the
link causes an AJAX form
+ submit on the server, "action1" method performance, and
rendering of the component
+ with "someData" id after the response comes back from the
server.</para>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxCommandLink;
+...
+HtmlAjaxCommandLink myLink = new HtmlAjaxCommandLink();
+...
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>The component <emphasis
role="bold"><property><a4j:commandLink></property></emphasis>
placed on a page generates the following HTML code:</para>
+ <programlisting role="JSP"><![CDATA[<a href="#"
onclick="A4J.AJAX.Submit(?"request parameters");
+ return
+ <a href="#" onclick="A4J.AJAX.Submit(?"request
parameters");
+ return false;">
+ <span style="color: black;">Link Value</span>
+ </a>
+]]></programlisting>
+ <para>Hence, the utility method "A4J.AJAX.Submit" is called
on a click, the method performs AJAX request as the <emphasis
role="bold"><property><a4j:support></property></emphasis>
component</para>
+ <note>
+ <title>Note:</title>
+ <para>AJAX support is built in and it's not necessary to add nested
<emphasis
role="bold"><property><a4j:support></property></emphasis>
to the component.</para>
+ </note>
+ <para>Common JSF navigation could be performed after AJAX submit and partial
rendering, but Navigation Case must be defined as <emphasis
role="bold"><property><redirect/></property></emphasis>
in order to avoid problems with some browsers.</para>
+ <para>As any Ajax4jsf component sending AJAX requests and processing server
responses <emphasis
role="bold"><property><a4j:commandLink></property></emphasis>
has all attributes described above (see <emphasis
role="bold"><property><a4j:support></property></emphasis>
chapter) that provide the required behavior of requests sending (delay, limitation of
submit area and rendering, etc.)</para>
+ </section>
+</chapter>
\ No newline at end of file
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/form.xml
===================================================================
--- trunk/docs/userguide/en/included/form.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/form.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -1,83 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <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.ajax.Form</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>javax.faces.Form</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.AjaxForm</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.FormRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>Component definition on a page is similar to definition of the original
component from JSF HTML library. </para>
- <programlisting role="XML"><![CDATA[<a4j:form>
- <!--...Some content to be submitted.-->
-</a4j:form>
-]]></programlisting>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.AjaxForm;
-...
-AjaxForm myForm = new org.ajax4jsf.ajax.html.AjaxForm();
-...
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>The difference with the original component is that all hidden fields
required for command links are always rendered and it doesn't depend on links
rendering on the initial page. It solves the problem with invalid links that weren't
rendered on a page immediately, but after some AJAX request.</para>
- <para>Beginning with release 1.0.5 additional attributes that make this form
variant universal appear. With a new attribute definition as ajax=<emphasis
role="italic">
- <property>"true"</property>
- </emphasis>, it becomes possible to set AJAX submission way for any
components inside, i.e. not a page URL is used as an <emphasis
role="italic">
- <property>"action"</property>
- </emphasis> attribute, but the javascript:A4J.AJAX.Submit(...) call. In this
case, rendering is defined as reRender=list of Ids for the form element
itself.</para>
- <para>Example</para>
- <programlisting role="XML"><![CDATA[<a4j:form
id="helloForm" ajaxSubmit="true" reRender="table">
- ...
- <t:dataTable id="table"... >
- ...
- </t:dataTable>
- ...
- <t:dataScroller for="table"... >
- ...
- </t:dataScroller>
- ...
-</a4j:form
-]]></programlisting>
-<para>This example shows that in order to make <emphasis
role="bold">
- <property><t:dataScroller></property>
- </emphasis> submissions to be AJAX ones it's required only to place this
<emphasis role="bold">
- <property><t:dataScroller></property>
- </emphasis> into <emphasis role="bold">
- <property><a4j:form></property>
- </emphasis>. In the other case it is necessary to redefine renders for its
child links elements that are defined as <emphasis role="bold">
- <property><h:commandLink></property>
- </emphasis> and can't be made AJAX ones with using e.g. <emphasis
role="bold">
- <property><a4j:support></property>
- </emphasis>.</para>
- </section>
-</chapter>
Copied: tags/1_1_1_rc1/docs/userguide/en/included/form.xml (from rev 163,
trunk/docs/userguide/en/included/form.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/form.xml (rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/form.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -0,0 +1,83 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <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.ajax.Form</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>javax.faces.Form</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.AjaxForm</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.FormRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>Component definition on a page is similar to definition of the original
component from JSF HTML library. </para>
+ <programlisting role="XML"><![CDATA[<a4j:form>
+ <!--...Some content to be submitted.-->
+</a4j:form>
+]]></programlisting>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.AjaxForm;
+...
+AjaxForm myForm = new AjaxForm();
+...
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>The difference with the original component is that all hidden fields
required for command links are always rendered and it doesn't depend on links
rendering on the initial page. It solves the problem with invalid links that weren't
rendered on a page immediately, but after some AJAX request.</para>
+ <para>Beginning with release 1.0.5 additional attributes that make this form
variant universal appear. With a new attribute definition as ajax=<emphasis
role="italic">
+ <property>"true"</property>
+ </emphasis>, it becomes possible to set AJAX submission way for any
components inside, i.e. not a page URL is used as an <emphasis
role="italic">
+ <property>"action"</property>
+ </emphasis> attribute, but the javascript:A4J.AJAX.Submit(...) call. In this
case, rendering is defined as reRender=list of Ids for the form element
itself.</para>
+ <para>Example</para>
+ <programlisting role="XML"><![CDATA[<a4j:form
id="helloForm" ajaxSubmit="true" reRender="table">
+ ...
+ <t:dataTable id="table"... >
+ ...
+ </t:dataTable>
+ ...
+ <t:dataScroller for="table"... >
+ ...
+ </t:dataScroller>
+ ...
+</a4j:form
+]]></programlisting>
+<para>This example shows that in order to make <emphasis
role="bold">
+ <property><t:dataScroller></property>
+ </emphasis> submissions to be AJAX ones it's required only to place this
<emphasis role="bold">
+ <property><t:dataScroller></property>
+ </emphasis> into <emphasis role="bold">
+ <property><a4j:form></property>
+ </emphasis>. In the other case it is necessary to redefine renders for its
child links elements that are defined as <emphasis role="bold">
+ <property><h:commandLink></property>
+ </emphasis> and can't be made AJAX ones with using e.g. <emphasis
role="bold">
+ <property><a4j:support></property>
+ </emphasis>.</para>
+ </section>
+</chapter>
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/htmlCommandLink.xml
===================================================================
--- trunk/docs/userguide/en/included/htmlCommandLink.xml 2007-05-02 17:40:09 UTC (rev
158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/htmlCommandLink.xml 2007-05-04 01:10:03 UTC
(rev 168)
@@ -1,68 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <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>javax.faces.HtmlCommandLink</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>javax.faces.Command</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>javax.faces.component.html.HtmlCommandLink</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.HtmlCommandLinkRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>Component definition on a page is the same as for the original component
from the JSF HTML library.</para>
- <programlisting role="XML"><![CDATA[<a4j:htmlCommandLink
value="value" action="action"/>
-]]></programlisting>
-</section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
javax.faces.component.html.HtmlCommandLink;
-...
-HtmlCommandLink myForm = new javax.faces.component.html.HtmlCommandLink();
-...
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>The difference with the original component is that all hidden fields
required for command links with child <emphasis role="bold">
- <property><f:param></property>
- </emphasis> elements are always rendered and it doesn't depend on links
rendering on the initial page. It solves the problem with invalid links that weren't
rendered on a page immediately, but after some AJAX request.</para>
- <programlisting role="XML"><![CDATA[<a4j:form>
- ...
- <a4j:htmlComandLink action="action" value="link"
-rendered="#{bean.rendered}">
-<f:param ...>
- <a4j:htmlComandLink>
- ...
-</a4j:form>
-]]></programlisting>
-<para>In this example <emphasis role="bold">
- <property><a4j:htmlCommandLink></property>
- </emphasis>works as standard <emphasis role="bold">
- <property><h:commandLink></property>
- </emphasis>, but here hidden fields required for correct functionality are
rendered before the first downloading of a page, though it doesn't happen if its
attribute isn't set to "false".</para>
- </section>
-</chapter>
Copied: tags/1_1_1_rc1/docs/userguide/en/included/htmlCommandLink.xml (from rev 163,
trunk/docs/userguide/en/included/htmlCommandLink.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/htmlCommandLink.xml
(rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/htmlCommandLink.xml 2007-05-04 01:10:03 UTC
(rev 168)
@@ -0,0 +1,67 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <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>javax.faces.HtmlCommandLink</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>javax.faces.Command</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>javax.faces.component.html.HtmlCommandLink</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.HtmlCommandLinkRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>Component definition on a page is the same as for the original component
from the JSF HTML library.</para>
+ <programlisting role="XML"><![CDATA[<a4j:htmlCommandLink
value="value" action="action"/>
+]]></programlisting>
+</section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
javax.faces.component.html.HtmlCommandLink;
+...
+HtmlCommandLink myForm = new HtmlCommandLink();
+...
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>The difference with the original component is that all hidden fields
required for command links with child <emphasis role="bold">
+ <property><f:param></property>
+ </emphasis> elements are always rendered and it doesn't depend on links
rendering on the initial page. It solves the problem with invalid links that weren't
rendered on a page immediately, but after some AJAX request.</para>
+ <programlisting role="XML"><![CDATA[<a4j:form>
+ ...
+ <a4j:htmlComandLink action="action" value="link"
rendered="#{bean.rendered}">
+ <f:param ...>
+ <a4j:htmlComandLink>
+ ...
+</a4j:form>
+]]></programlisting>
+<para>In this example <emphasis role="bold">
+ <property><a4j:htmlCommandLink></property>
+ </emphasis>works as standard <emphasis role="bold">
+ <property><h:commandLink></property>
+ </emphasis>, but here hidden fields required for correct functionality are
rendered before the first downloading of a page, though it doesn't happen if its
attribute isn't set to "false".</para>
+ </section>
+</chapter>
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/include.xml
===================================================================
--- trunk/docs/userguide/en/included/include.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/include.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,83 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <para><table frame="all">
- <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.ajax.Include</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>org.ajax4jsf.ajax.Output</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.Include</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.AjaxIncludeRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table></para>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>To use the component, it's necessary to place the following
strings on a page:</para>
- <programlisting role="XML"><![CDATA[<h:panelGroup
id="wizard">
- <a4j:include viewId="/pages/include/first.xhtml" />
-</h:panelGroup>
-]]></programlisting>
-<para>For navigation inside a page defined in viewId any components responsible for
AJAX requests to the server generation are used.</para>
-<para>For example, the following component on the page
"/pages/include/first.xhtml"</para>
-<programlisting role="XML"><![CDATA[...
-<a4j:commandButton action="next" reRender="wizard"/>
-...
-]]></programlisting>
-<para>And in faces-config it's defined:</para>
-<programlisting role="XML"><![CDATA[<navigation-rule>
- <from-view-id>/pages/include/first.xhtml</from-view-id>
- <navigation-case>
- <from-outcome>next</from-outcome>
- <to-view-id>/pages/include/second.xhtml</to-view-id>
- </navigation-case>
- </navigation-rule>
-]]></programlisting>
-<para>In this case after a click on a button defined inside
"first.xhtml" view, navigation is performed after an AJAX request (the
same as standard JSF one) only inside this view.</para>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="XML"><![CDATA[<a4j:outputPanel
ajaxRendered="true">
- <a4j:include viewId="/pages/include/first.xhtml"/>
-</a4j:outputPanel>
-]]></programlisting>
-<para>If <emphasis role="bold">
- <property><a4j:include></property>
- </emphasis> is defined this way, any AJAX request returning outcome inside
generates navigation with this <emphasis role="bold">
- <property><a4j:include></property>
- </emphasis>.</para>
-<para>Ajax Action for navigation implementation inside view must be placed inside
<emphasis role="bold">
- <property><a4j:include></property>
- </emphasis> pages. Navigation defined by these pages is applied to the
<emphasis role="bold">
- <property><a4j:include></property>
- </emphasis> element current for them.</para>
-<para>As in general case for Ajax Action component, if the <emphasis
role="bold">
- <property><a4j:action></property>
- </emphasis>component inside <emphasis role="bold">
- <property><a4j:include></property>
- </emphasis>returns outcome defined as <emphasis role="bold">
- <property><redirect/></property>
- </emphasis>, AJAX submit is performed with navigation of all page and not
only of the current view.
-</para>
-</section>
-</chapter>
\ No newline at end of file
Copied: tags/1_1_1_rc1/docs/userguide/en/included/include.xml (from rev 163,
trunk/docs/userguide/en/included/include.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/include.xml (rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/include.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,83 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <para><table frame="all">
+ <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.ajax.Include</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>org.ajax4jsf.ajax.Output</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.Include</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.AjaxIncludeRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>To use the component, it's necessary to place the following
strings on a page:</para>
+ <programlisting role="XML"><![CDATA[<h:panelGroup
id="wizard">
+ <a4j:include viewId="/pages/include/first.xhtml" />
+</h:panelGroup>
+]]></programlisting>
+<para>For navigation inside a page defined in viewId any components responsible for
AJAX requests to the server generation are used.</para>
+<para>For example, the following component on the page
"/pages/include/first.xhtml"</para>
+<programlisting role="XML"><![CDATA[...
+<a4j:commandButton action="next" reRender="wizard"/>
+...
+]]></programlisting>
+<para>And in faces-config it's defined:</para>
+<programlisting role="XML"><![CDATA[<navigation-rule>
+ <from-view-id>/pages/include/first.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>next</from-outcome>
+ <to-view-id>/pages/include/second.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+]]></programlisting>
+<para>In this case after a click on a button defined inside
"first.xhtml" view, navigation is performed after an AJAX request (the
same as standard JSF one) only inside this view.</para>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="XML"><![CDATA[<a4j:outputPanel
ajaxRendered="true">
+ <a4j:include viewId="/pages/include/first.xhtml"/>
+</a4j:outputPanel>
+]]></programlisting>
+<para>If <emphasis role="bold">
+ <property><a4j:include></property>
+ </emphasis> is defined this way, any AJAX request returning outcome inside
generates navigation with this <emphasis role="bold">
+ <property><a4j:include></property>
+ </emphasis>.</para>
+<para>Ajax Action for navigation implementation inside view must be placed inside
<emphasis role="bold">
+ <property><a4j:include></property>
+ </emphasis> pages. Navigation defined by these pages is applied to the
<emphasis role="bold">
+ <property><a4j:include></property>
+ </emphasis> element current for them.</para>
+<para>As in general case for Ajax Action component, if the <emphasis
role="bold">
+ <property><a4j:action></property>
+ </emphasis>component inside <emphasis role="bold">
+ <property><a4j:include></property>
+ </emphasis>returns outcome defined as <emphasis role="bold">
+ <property><redirect/></property>
+ </emphasis>, AJAX submit is performed with navigation of all page and not
only of the current view.
+</para>
+</section>
+</chapter>
\ No newline at end of file
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/jsFunction.xml
===================================================================
--- trunk/docs/userguide/en/included/jsFunction.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/jsFunction.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<chapter>
- <section>
- <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.ajax.Function</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>org.ajax4jsf.components.AjaxFunction</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.HtmlAjaxFunction</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.components.AjaxFunctionRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>Simple component definition example:</para>
- <programlisting role="XML"><![CDATA[...
- <head>
- <script>
- <!--There is some script named "myScript" that uses parameters which
will be taken from server-->
- </script>
- </head>
- <body>
- ...
- <a4j:jsFunction data="#{bean.someProperty}" name="callScript"
oncomplete="myScript(data.subProperty1, data.subProperty2)"/>
- ...]]>
- </programlisting>
- <para>
- The script "myScript" will be called after
<property>bean.someProperty</property> data
- will be returned from server(e.g. It'll be object with two subproperties).
- </para>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxFunction;
-...
-AjaxFunction myFunction = new org.ajax4jsf.ajax.html.HtmlAjaxFunction();
-...
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>
- As the component uses Ajax request to get data from server - it has all
- common Ajax Action attributes. So, action and actionListener can be
- invoked, and reRendering some parts of the page fired after calling
- function.
- </para>
- </section>
-</chapter>
\ No newline at end of file
Copied: tags/1_1_1_rc1/docs/userguide/en/included/jsFunction.xml (from rev 163,
trunk/docs/userguide/en/included/jsFunction.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/jsFunction.xml (rev
0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/jsFunction.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<chapter>
+ <section>
+ <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.ajax.Function</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>org.ajax4jsf.components.AjaxFunction</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.HtmlAjaxFunction</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.components.AjaxFunctionRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>Simple component definition example:</para>
+ <programlisting role="XML"><![CDATA[...
+<head>
+ <script>
+ <!--There is some script named "myScript" that uses parameters which will
be taken from server-->
+ </script>
+</head>
+<body>
+...
+<a4j:jsFunction data="#{bean.someProperty}" name="callScript"
oncomplete="myScript(data.subProperty1, data.subProperty2)"/>
+...]]>
+ </programlisting>
+ <para>
+ The script "myScript" will be called after
<property>bean.someProperty</property> data
+ will be returned from server(e.g. It'll be object with two subproperties).
+ </para>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxFunction;
+...
+HtmlAjaxFunction myFunction = new HtmlAjaxFunction();
+...
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>
+ As the component uses Ajax request to get data from server - it has all
+ common Ajax Action attributes. So, action and actionListener can be
+ invoked, and reRendering some parts of the page fired after calling
+ function.
+ </para>
+ </section>
+</chapter>
\ No newline at end of file
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/loadScript.xml
===================================================================
--- trunk/docs/userguide/en/included/loadScript.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/loadScript.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<chapter>
- <section>
- <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.LoadScript</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>org.ajax4jsf.LoadScript</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.HtmlLoadScript</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.LoadScriptRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>Simple Component definition on a page:</para>
- <programlisting role="XML"><![CDATA[<a4j:loadScript
src="scripts/someScript.js"/>
-]]></programlisting>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlLoadScript;
-...
-HtmlLoadScript myScript = new org.ajax4jsf.ajax.html.HtmlLoadScript();
-...
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>
- As it was mentioned before this componment returns its value passing it to the
- getResourceUR() method of the ViewHandler for this application, and passing
- the result through the encodeResourceURL() method of the ExternalContext.
- </para>
- <para>
- It means that the Context will be inserts automatically to the link. And calls
- like <property>resource://</property> will be properly handled.
- </para>
- <para>
- Except this - you may be free to put your script links right from the child
- page while using <property>facelets templates</property> .
- </para>
-</section>
-</chapter>
\ No newline at end of file
Copied: tags/1_1_1_rc1/docs/userguide/en/included/loadScript.xml (from rev 163,
trunk/docs/userguide/en/included/loadScript.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/loadScript.xml (rev
0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/loadScript.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<chapter>
+ <section>
+ <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.LoadScript</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>org.ajax4jsf.LoadScript</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.HtmlLoadScript</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.LoadScriptRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>Simple Component definition on a page:</para>
+ <programlisting role="XML"><![CDATA[<a4j:loadScript
src="scripts/someScript.js"/>
+]]></programlisting>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlLoadScript;
+...
+HtmlLoadScript myScript = new HtmlLoadScript();
+...
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>
+ As it was mentioned before this componment returns its value passing it to the
+ getResourceUR() method of the ViewHandler for this application, and passing
+ the result through the encodeResourceURL() method of the ExternalContext.
+ </para>
+ <para>
+ It means that the Context will be inserts automatically to the link. And calls
+ like <property>resource://</property> will be properly handled.
+ </para>
+ <para>
+ Except this - you may be free to put your script links right from the child
+ page while using <property>facelets templates</property> .
+ </para>
+</section>
+</chapter>
\ No newline at end of file
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/log.xml
===================================================================
--- trunk/docs/userguide/en/included/log.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/log.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -1,64 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <para><table frame="all">
- <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.ajax.Log</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>org.ajax4jsf.ajax.Log</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.AjaxLog</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.LogRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table></para>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>To use the component, it's necessary to place the following
string on a page:</para><programlisting
role="XML"><![CDATA[<a4j:log/>]]></programlisting>
- <para>Then, in order to open a log window, press
"CTRL+SHIFT+L" on a page with the component.</para>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.AjaxLog;
-...
-AjaxLog myLog = new org.ajax4jsf.ajax.html.AjaxLog();
-...]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>Usage of the appropriate component attributes could change a
representation level of debug information as well as the hot key for a window
opening.</para>
- <para>The hot key could be changed with the <emphasis
role="italic">
- <property>"hotkey"</property>
- </emphasis>
-attribute, where it's necessary to define one letter that together with
"CTRL+SHIFT" opens a window.</para>
- <para>The <emphasis role="italic">
- <property>"level"</property>
- </emphasis>
-attribute with several possible values (FATAL, ERROR, WARN, INFO, ALL) could change a
logging level.</para>
- <para>The log could be generated not only in a new window, but also on the
current page in a separate <emphasis
role="bold"><property><div></property></emphasis>,
this is also controlled with the <emphasis role="italic">
- <property>"popup"</property>
- </emphasis>
-attribute on the component. </para>
- <para>Example:</para><programlisting
role="XML"><![CDATA[<a4j:log level="ALL"
popup="false" width="400"
height="200"/>]]></programlisting>
- <para>The component defined this way is decoded on a page as <emphasis
role="bold"><property><div></property></emphasis>
inside a page, where all the information beginning with informational message is
generated.</para>
- </section>
-</chapter>
Copied: tags/1_1_1_rc1/docs/userguide/en/included/log.xml (from rev 163,
trunk/docs/userguide/en/included/log.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/log.xml (rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/log.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -0,0 +1,64 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <para><table frame="all">
+ <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.ajax.Log</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>org.ajax4jsf.ajax.Log</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.AjaxLog</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.LogRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>To use the component, it's necessary to place the following
string on a page:</para><programlisting
role="XML"><![CDATA[<a4j:log/>]]></programlisting>
+ <para>Then, in order to open a log window, press
"CTRL+SHIFT+L" on a page with the component.</para>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.AjaxLog;
+...
+AjaxLog myLog = new AjaxLog();
+...]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>Usage of the appropriate component attributes could change a
representation level of debug information as well as the hot key for a window
opening.</para>
+ <para>The hot key could be changed with the <emphasis
role="italic">
+ <property>"hotkey"</property>
+ </emphasis>
+attribute, where it's necessary to define one letter that together with
"CTRL+SHIFT" opens a window.</para>
+ <para>The <emphasis role="italic">
+ <property>"level"</property>
+ </emphasis>
+attribute with several possible values (FATAL, ERROR, WARN, INFO, ALL) could change a
logging level.</para>
+ <para>The log could be generated not only in a new window, but also on the
current page in a separate <emphasis
role="bold"><property><div></property></emphasis>,
this is also controlled with the <emphasis role="italic">
+ <property>"popup"</property>
+ </emphasis>
+attribute on the component. </para>
+ <para>Example:</para><programlisting
role="XML"><![CDATA[<a4j:log level="ALL"
popup="false" width="400"
height="200"/>]]></programlisting>
+ <para>The component defined this way is decoded on a page as <emphasis
role="bold"><property><div></property></emphasis>
inside a page, where all the information beginning with informational message is
generated.</para>
+ </section>
+</chapter>
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/mediaOutput.xml
===================================================================
--- trunk/docs/userguide/en/included/mediaOutput.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/mediaOutput.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,83 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <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.MediaOutput</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>org.ajax4jsf.Resource</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.MediaOutput</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.MediaOutputRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>To use the component it's necessary to define it on a page and
set Java methods for data keeping and data transmission to output stream. </para>
- <para>Component definition on a page for graphical data output</para>
- <programlisting role="XML"><![CDATA[...
-<a4j:mediaOutput element="img" cacheable="false"
session="true"
- createContent="#{paintBean.paint}" value="#{paintData}"
- mimeType="image/jpeg"/>
-...
-]]></programlisting>
-<para>Here is the content of paintData that is a bean containing output
data</para>
-<programlisting role="JAVA"><![CDATA[package demo;
-public class PaintData implements Serializable{
- private static final long serialVersionUID = 1L;
- Integer Width=100;
- Integer Height=50;
-...
-]]></programlisting>
-<para>The Paint method of the paintBean class is a method transmitting graphical
data into output stream.</para>
-<programlisting role="JAVA"><![CDATA[public void paint(OutputStream
out, Object data) throws IOException{
- <!--...Some code that puts binary data to "out" Stream-->
- }
-]]></programlisting>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.MediaOutput;
-...
-MediaOutput myMedia = new org.ajax4jsf.ajax.html.MediaOutput ();
-...
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>As it was shown in the example above there are two main
components:</para>
- <itemizedlist>
- <listitem>
- createContent specifies a method accepting 2 parameters. The first (of
java.io.OutputStream type) defines a stream, where any binary data is output. The second
(of java.lang.Object type) contains deserialized object with data specified in the
<emphasis role="italic">
- <property>"value"</property>
- </emphasis> attribute.
- </listitem>
- <listitem>
- Value specifies a bean class keeping data for transmitting into a method that
transmits it into a stream.
- </listitem>
- </itemizedlist>
- <note><title>Note:</title>A bean class transmitted into value should
implement Serializable interface.
- </note>
- <para>Hence, when using the component it's possible to output user data of
any type on a page with AJAX requests.</para>
- </section>
-</chapter>
\ No newline at end of file
Copied: tags/1_1_1_rc1/docs/userguide/en/included/mediaOutput.xml (from rev 163,
trunk/docs/userguide/en/included/mediaOutput.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/mediaOutput.xml (rev
0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/mediaOutput.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,84 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <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.MediaOutput</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>org.ajax4jsf.Resource</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.MediaOutput</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.MediaOutputRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>To use the component it's necessary to define it on a page and
set Java methods for data keeping and data transmission to output stream. </para>
+ <para>Component definition on a page for graphical data output</para>
+ <programlisting role="XML"><![CDATA[...
+<a4j:mediaOutput element="img" cacheable="false"
session="true"
+ createContent="#{paintBean.paint}" value="#{paintData}"
+ mimeType="image/jpeg"/>
+...
+]]></programlisting>
+<para>Here is the content of paintData that is a bean containing output
data</para>
+<programlisting role="JAVA"><![CDATA[package demo;
+
+public class PaintData implements Serializable{
+ private static final long serialVersionUID = 1L;
+ Integer width=100;
+ Integer weight=50;
+...
+]]></programlisting>
+<para>The Paint method of the paintBean class is a method transmitting graphical
data into output stream.</para>
+<programlisting role="JAVA"><![CDATA[public void paint(OutputStream
out, Object data) throws IOException{
+ <!--...Some code that puts binary data to "out" Stream-->
+ }
+]]></programlisting>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.MediaOutput;
+...
+MediaOutput myMedia = new MediaOutput ();
+...
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>As it was shown in the example above there are two main
components:</para>
+ <itemizedlist>
+ <listitem>
+ createContent specifies a method accepting 2 parameters. The first (of
java.io.OutputStream type) defines a stream, where any binary data is output. The second
(of java.lang.Object type) contains deserialized object with data specified in the
<emphasis role="italic">
+ <property>"value"</property>
+ </emphasis> attribute.
+ </listitem>
+ <listitem>
+ Value specifies a bean class keeping data for transmitting into a method that
transmits it into a stream.
+ </listitem>
+ </itemizedlist>
+ <note><title>Note:</title>A bean class transmitted into value should
implement Serializable interface.
+ </note>
+ <para>Hence, when using the component it's possible to output user data of
any type on a page with AJAX requests.</para>
+ </section>
+</chapter>
\ No newline at end of file
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/outputPanel.xml
===================================================================
--- trunk/docs/userguide/en/included/outputPanel.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/outputPanel.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,122 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <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.ajax.OutputPanel</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>javax.faces.Panel</entry>
- </row>
- <row>
- <entry>component-type</entry>
- <entry>org.ajax4jsf.ajax.OutputPanel</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.HtmlAjaxOutputPanel</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.components.AjaxOutputPanelRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>Here is the simplest way for a component creation on a
page.</para>
- <programlisting role="XML"><![CDATA[<a4j:outputPanel>
-<!--...Some Content Inside-->
-</a4j:outputPanel>
-]]></programlisting>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxOutputPanel;
-...
-HtmlAjaxOutputPanel myPanel = new HtmlAjaxOutputPanel();
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para><emphasis
role="bold"><property><a4j:outPanel></property></emphasis>
allows marking of a page area, which is updated on Ajax response. Anyway, <emphasis
role="bold">
- <property><a4j:outputPanel></property>
- </emphasis> usage is optional, as in Ajax4jsf it's possible to
indicate any existing component id on a component view in order to define updating areas.
-
-To speed up the performance, Ajax4jsf updates only a component tree. <emphasis
role="bold">
- <property><a4j:outputPanel></property>
- </emphasis> usage is recommended for wrapping components that aren't
rendered during the primary non-ajax response, as the components don't present in
a component tree.
-</para>
- <para><emphasis
role="bold">Example:</emphasis></para>
- <programlisting role="XML"><![CDATA[<a4j:support ...
reRender="mypanel"/>
-...
-<a4j:outputPanel id="mypanel">
- <h:panelGrid rendered="#{not empty foo.bar}">
-...
- </h:panelGrid>
-</a4j:outputPanel>
-]]></programlisting>
- <para>In addition to the areas directly indicated in reRender attribute of Ajax
components, <emphasis role="bold">
- <property><a4j:outputPanel></property>
- </emphasis> allows to update a part of a page basing on its own flag. The
flag is defined by the ajaxRendered attribute. The flag is commonly used when a part of a
page must be updated or can be updated on any response.</para>
- <para><emphasis
role="bold">Example:</emphasis></para>
- <programlisting role="XML"><![CDATA[<a4j:outputPanel
ajaxRendered="true">
- <h:messages/>
-</a4j:outputPanel>
-]]></programlisting>
- <para>On default <emphasis role="bold">
- <property><a4j:outputPanel></property>
- </emphasis> is output as a pair of opening and closing html <emphasis
role="bold"><property><span></property></emphasis>
tag, but with the help of the layout attribute this output way could be changed. There are
three variants for this component value:</para>
- <itemizedlist>
- <listitem>
- inline (default)
- </listitem>
- <listitem>
- block
- </listitem>
- <listitem>
- none
- </listitem>
- </itemizedlist>
- <para>If layout="block" is chosen, the component is rendered
as a pair of opening and closing <emphasis
role="bold"><property><div></property></emphasis>
tag, to which it’s possible to apply any available style attributes available for block
tags. </para>
- <para>Layout="none" helps to avoid an unnecessary tag round a
context that could or couldn't be rendered according to the defined
"rendered" attribute conditions. If an inner context isn’t rendered,
<emphasis role="bold">
- <property><a4j:outputPanel></property>
- </emphasis> is rendered as a <emphasis
role="bold"><property><span></property></emphasis>
tag with the id equal to an id of a child component and "display:none"
style. If a child component is rendered, <emphasis role="bold">
- <property><a4j:outputPanel></property>
- </emphasis> doesn't present at all in a final code.</para>
- <para><emphasis
role="bold">Example:</emphasis></para>
- <programlisting role="XML"><![CDATA[<a4j:support ....
reRender="mypanel"/>
-...
-<a4j:outputPanel layout="none">
- <h:panelGrid id="mypanel" rendered="#{not empty foo.bar}">
-...
- </h:panelGrid>
-</a4j:outputPanel>
-]]></programlisting>
- <para>As you see, the code is very similar to the one shown above, but
<emphasis role="italic"><property>"reRender
"</property></emphasis> attribute refers directly to the updating
panelGrid and not to the framing outputPanel, and it's more semantically
correct.</para>
- <para><emphasis
role="bold"><property><a4j:outPanel></property></emphasis>
should be used for non-JSF component part framing, which is to be updated on Ajax
response, as Ajax4jsf specifies the list of updating areas as a list of an existing JSF
component. </para>
- <para>On default non-JSF context isn't saved in a component tree, but
is rendered anew every time. To accelerate the processing speed and Ajax response input
speed, Ajax4jsf saves non-JSF context in a component tree on default. This option could be
canceled by keepTransient attribute that cancels transient flag forced setting for child
components. This flag setting keeps the current value set by child
components.</para>
- <para>Note: In JSF 1.1 implementation and lower, where non-JSF context should
be framed with the "f:verbatim" attribute, <emphasis
role="bold">
- <property><a4j:outputPanel></property>
- </emphasis> doesn't improve this JSF implementation option in any
way, so you still have to use this tag where it's necessary without Ajax4jsf
usage. </para>
- <para>Ajax4jsf allows setting Ajax responses rendering directly basing on
component tree nodes without referring to the JSP (XHTML) page code. It could be defined
by selfRendered attribute setting to <emphasis role="italic">
- <property>"true"</property>
- </emphasis>
- on <emphasis role="bold">
- <property><a4j:region></property>
- </emphasis> and could help considerably speed up a response output. However,
if a transient flag is kept as it is, this rapid processing could cause missing of
transient components that present on view and don’t come into a component tree. Hence, for
any particular case you could choose a way for you application optimization: speed up
processing or redundant memory for keeping tree part earlier defined a transient.
</para>
- </section>
-</chapter>
\ No newline at end of file
Copied: tags/1_1_1_rc1/docs/userguide/en/included/outputPanel.xml (from rev 163,
trunk/docs/userguide/en/included/outputPanel.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/outputPanel.xml (rev
0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/outputPanel.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,122 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <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.ajax.OutputPanel</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>javax.faces.Panel</entry>
+ </row>
+ <row>
+ <entry>component-type</entry>
+ <entry>org.ajax4jsf.ajax.OutputPanel</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.HtmlAjaxOutputPanel</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.components.AjaxOutputPanelRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>Here is the simplest way for a component creation on a
page.</para>
+ <programlisting role="XML"><![CDATA[<a4j:outputPanel>
+<!--...Some Content Inside-->
+</a4j:outputPanel>
+]]></programlisting>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxOutputPanel;
+...
+HtmlAjaxOutputPanel myPanel = new HtmlAjaxOutputPanel();
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para><emphasis
role="bold"><property><a4j:outPanel></property></emphasis>
allows marking of a page area, which is updated on Ajax response. Anyway, <emphasis
role="bold">
+ <property><a4j:outputPanel></property>
+ </emphasis> usage is optional, as in Ajax4jsf it's possible to
indicate any existing component id on a component view in order to define updating areas.
+
+To speed up the performance, Ajax4jsf updates only a component tree. <emphasis
role="bold">
+ <property><a4j:outputPanel></property>
+ </emphasis> usage is recommended for wrapping components that aren't
rendered during the primary non-ajax response, as the components don't present in
a component tree.
+</para>
+ <para><emphasis
role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<a4j:support ...
reRender="mypanel"/>
+...
+<a4j:outputPanel id="mypanel">
+ <h:panelGrid rendered="#{not empty foo.bar}">
+ ...
+ </h:panelGrid>
+</a4j:outputPanel>
+]]></programlisting>
+ <para>In addition to the areas directly indicated in reRender attribute of Ajax
components, <emphasis role="bold">
+ <property><a4j:outputPanel></property>
+ </emphasis> allows to update a part of a page basing on its own flag. The
flag is defined by the ajaxRendered attribute. The flag is commonly used when a part of a
page must be updated or can be updated on any response.</para>
+ <para><emphasis
role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<a4j:outputPanel
ajaxRendered="true">
+ <h:messages/>
+</a4j:outputPanel>
+]]></programlisting>
+ <para>On default <emphasis role="bold">
+ <property><a4j:outputPanel></property>
+ </emphasis> is output as a pair of opening and closing html <emphasis
role="bold"><property><span></property></emphasis>
tag, but with the help of the layout attribute this output way could be changed. There are
three variants for this component value:</para>
+ <itemizedlist>
+ <listitem>
+ inline (default)
+ </listitem>
+ <listitem>
+ block
+ </listitem>
+ <listitem>
+ none
+ </listitem>
+ </itemizedlist>
+ <para>If layout="block" is chosen, the component is rendered
as a pair of opening and closing <emphasis
role="bold"><property><div></property></emphasis>
tag, to which it’s possible to apply any available style attributes available for block
tags. </para>
+ <para>Layout="none" helps to avoid an unnecessary tag round a
context that could or couldn't be rendered according to the defined
"rendered" attribute conditions. If an inner context isn’t rendered,
<emphasis role="bold">
+ <property><a4j:outputPanel></property>
+ </emphasis> is rendered as a <emphasis
role="bold"><property><span></property></emphasis>
tag with the id equal to an id of a child component and "display:none"
style. If a child component is rendered, <emphasis role="bold">
+ <property><a4j:outputPanel></property>
+ </emphasis> doesn't present at all in a final code.</para>
+ <para><emphasis
role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<a4j:support ....
reRender="mypanel"/>
+...
+<a4j:outputPanel layout="none">
+ <h:panelGrid id="mypanel" rendered="#{not empty foo.bar}">
+ ...
+ </h:panelGrid>
+</a4j:outputPanel>
+]]></programlisting>
+ <para>As you see, the code is very similar to the one shown above, but
<emphasis role="italic"><property>"reRender
"</property></emphasis> attribute refers directly to the updating
panelGrid and not to the framing outputPanel, and it's more semantically
correct.</para>
+ <para><emphasis
role="bold"><property><a4j:outPanel></property></emphasis>
should be used for non-JSF component part framing, which is to be updated on Ajax
response, as Ajax4jsf specifies the list of updating areas as a list of an existing JSF
component. </para>
+ <para>On default non-JSF context isn't saved in a component tree, but
is rendered anew every time. To accelerate the processing speed and Ajax response input
speed, Ajax4jsf saves non-JSF context in a component tree on default. This option could be
canceled by keepTransient attribute that cancels transient flag forced setting for child
components. This flag setting keeps the current value set by child
components.</para>
+ <para>Note: In JSF 1.1 implementation and lower, where non-JSF context should
be framed with the "f:verbatim" attribute, <emphasis
role="bold">
+ <property><a4j:outputPanel></property>
+ </emphasis> doesn't improve this JSF implementation option in any
way, so you still have to use this tag where it's necessary without Ajax4jsf
usage. </para>
+ <para>Ajax4jsf allows setting Ajax responses rendering directly basing on
component tree nodes without referring to the JSP (XHTML) page code. It could be defined
by selfRendered attribute setting to <emphasis role="italic">
+ <property>"true"</property>
+ </emphasis>
+ on <emphasis role="bold">
+ <property><a4j:region></property>
+ </emphasis> and could help considerably speed up a response output. However,
if a transient flag is kept as it is, this rapid processing could cause missing of
transient components that present on view and don’t come into a component tree. Hence, for
any particular case you could choose a way for you application optimization: speed up
processing or redundant memory for keeping tree part earlier defined a transient.
</para>
+ </section>
+</chapter>
\ No newline at end of file
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/page.xml
===================================================================
--- trunk/docs/userguide/en/included/page.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/page.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -1,87 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <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.Page</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>org.ajax4jsf.components.AjaxRegion.</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.components.Page</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.components.PageRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>This component should be defined as a child component for <emphasis
role="bold">
- <property><f:view></property>
- </emphasis></para>
- <programlisting role="XML"><![CDATA[<f:view>
- <a4j:page>
- <f:facet name="head">
- <!--...Head Content here-->
- </f:facet>
- <!--...Page Content here-->
- </a4j:page>
-</f:view>
-]]></programlisting>
- <para>This structure is rendered as:</para>
- <programlisting role="XML"><![CDATA[<HTML>
- <HEAD>
- <!--...Head Content here-->
- </HEAD>
-<body >
- <!--...Page Content Here-->
-</body>
-</HTML>]]></programlisting>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.components.Page;
-...
-Page myPage = new org.ajax4jsf.components.Page();
-...
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>The component is mostly used to solve the following problem with MyFaces
for erlier Ajax4gsf versions: in MyFaces <emphasis role="bold">
- <property><f:view></property>
- </emphasis> doesn't get control over the "<emphasis
role="italic">
- <property>RENDER_RESPONSE</property>
- </emphasis>" phase, thus AJAX can't get control and make a
response also. To avoid this problem it was necessary to use <emphasis
role="bold">
- <property><a4j:page></property>
- </emphasis> on the page round the AJAX updatable area. In the last versions
of both frameworks the problem is successfully fixed and no <emphasis
role="bold"><property><a4j:page></property></emphasis>
usage is required.</para>
- <para>The component is rendered as a full HTML page template (it was shown in
the example). The "<emphasis role="italic">
- <property>head</property>
- </emphasis>" section is defined with the help of the corresponding
facet with the name="head" and also there is an attribute with the same
name for contentType definition.</para>
- <para>All other component functionality is the same as of <emphasis
role="bold">
- <property><a4j:region></property>
- </emphasis>. Its desctriprion could be found
-<member>
- <ulink
url="http://webdownload.exadel.com/downloads/ajax4jsf/documentation/...
-</member> </para>
-
-
- </section>
-</chapter>
Copied: tags/1_1_1_rc1/docs/userguide/en/included/page.xml (from rev 163,
trunk/docs/userguide/en/included/page.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/page.xml (rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/page.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -0,0 +1,87 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <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.Page</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>org.ajax4jsf.components.AjaxRegion.</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.components.Page</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.components.PageRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>This component should be defined as a child component for <emphasis
role="bold">
+ <property><f:view></property>
+ </emphasis></para>
+ <programlisting role="XML"><![CDATA[<f:view>
+ <a4j:page>
+ <f:facet name="head">
+ <!--...Head Content here-->
+ </f:facet>
+ <!--...Page Content here-->
+ </a4j:page>
+</f:view>
+]]></programlisting>
+ <para>This structure is rendered as:</para>
+ <programlisting role="XML"><![CDATA[<HTML>
+ <HEAD>
+ <!--...Head Content here-->
+ </HEAD>
+<body >
+ <!--...Page Content Here-->
+</body>
+</HTML>]]></programlisting>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.components.Page;
+...
+Page myPage = new Page();
+...
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>The component is mostly used to solve the following problem with MyFaces
for erlier Ajax4gsf versions: in MyFaces <emphasis role="bold">
+ <property><f:view></property>
+ </emphasis> doesn't get control over the "<emphasis
role="italic">
+ <property>RENDER_RESPONSE</property>
+ </emphasis>" phase, thus AJAX can't get control and make a
response also. To avoid this problem it was necessary to use <emphasis
role="bold">
+ <property><a4j:page></property>
+ </emphasis> on the page round the AJAX updatable area. In the last versions
of both frameworks the problem is successfully fixed and no <emphasis
role="bold"><property><a4j:page></property></emphasis>
usage is required.</para>
+ <para>The component is rendered as a full HTML page template (it was shown in
the example). The "<emphasis role="italic">
+ <property>head</property>
+ </emphasis>" section is defined with the help of the corresponding
facet with the name="head" and also there is an attribute with the same
name for contentType definition.</para>
+ <para>All other component functionality is the same as of <emphasis
role="bold">
+ <property><a4j:region></property>
+ </emphasis>. Its desctriprion could be found
+<member>
+ <ulink
url="http://webdownload.exadel.com/downloads/ajax4jsf/documentation/...
+</member> </para>
+
+
+ </section>
+</chapter>
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/poll.xml
===================================================================
--- trunk/docs/userguide/en/included/poll.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/poll.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -1,73 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <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.Poll</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>org.ajax4jsf.components.AjaxPoll</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.components.AjaxPoll</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.components.AjaxPollRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>To use this component it's necessary only to set an update
interval.</para>
- <programlisting role="XML"><![CDATA[<a4j:poll
interval="1000" reRender="someDataTable"
action="#{bean.action1}"/>
-]]></programlisting>
- <para>The <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> component defined this way every second submits AJAX form onto
the server, performs the corresponding action and renders a components with the
<emphasis role="italic">
- <property>"someDataTable"</property>
- </emphasis> id after a response comes back.</para>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.components.Page;
-import org.ajax4jsf.ajax.html.AjaxPoll;
-...
-AjaxPoll myPoll = new org.ajax4jsf.ajax.html.AjaxPoll();
-...
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>The component decodes all necessary JavaScript for time count and on the
expiry of some interval for calling of a Ajax4jsf utility method for Ajax request sending
(A4J.AJAX.Submit( Some request parameters)).
- </para>
- <para>
- The timer could be stopped or started in any time. The current state is controlled on
the component with the <emphasis role="italic">
- <property>"enabled"</property>
- </emphasis> attribute:
- </para>
- <programlisting role="XML"><![CDATA[<a4j:poll
interval="1000" enabled="#{bean.boolProperty}"/>
-]]></programlisting>
-<para>As any Ajax4jsf Action component, <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> has all described in the <emphasis role="bold">
- <property><ulink
url="ch06s05.html"><a4j:support></ulink></property>
- </emphasis> chapter attributes to provide the necessary behavior of request
sending (delay, limitation of a submit and render area, requests frequency, and etc.). For
detailed information on these attributes see again the <emphasis
role="bold">
- <property><ulink
url="ch06s05.html"><a4j:support></ulink></property></emphasis>
component description.
- </para>
- </section>
-</chapter>
\ No newline at end of file
Copied: tags/1_1_1_rc1/docs/userguide/en/included/poll.xml (from rev 163,
trunk/docs/userguide/en/included/poll.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/poll.xml (rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/poll.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -0,0 +1,72 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <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.Poll</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>org.ajax4jsf.components.AjaxPoll</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.components.AjaxPoll</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.components.AjaxPollRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>To use this component it's necessary only to set an update
interval.</para>
+ <programlisting role="XML"><![CDATA[<a4j:poll
interval="1000" reRender="someDataTable"
action="#{bean.action1}"/>
+]]></programlisting>
+ <para>The <emphasis role="bold">
+ <property><a4j:poll></property>
+ </emphasis> component defined this way every second submits AJAX form onto
the server, performs the corresponding action and renders a components with the
<emphasis role="italic">
+ <property>"someDataTable"</property>
+ </emphasis> id after a response comes back.</para>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.AjaxPoll;
+...
+AjaxPoll myPoll = new AjaxPoll();
+...
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>The component decodes all necessary JavaScript for time count and on the
expiry of some interval for calling of a Ajax4jsf utility method for Ajax request sending
(A4J.AJAX.Submit( Some request parameters)).
+ </para>
+ <para>
+ The timer could be stopped or started in any time. The current state is controlled on
the component with the <emphasis role="italic">
+ <property>"enabled"</property>
+ </emphasis> attribute:
+ </para>
+ <programlisting role="XML"><![CDATA[<a4j:poll
interval="1000" enabled="#{bean.boolProperty}"/>
+]]></programlisting>
+<para>As any Ajax4jsf Action component, <emphasis role="bold">
+ <property><a4j:poll></property>
+ </emphasis> has all described in the <emphasis role="bold">
+ <property><ulink
url="ch06s05.html"><a4j:support></ulink></property>
+ </emphasis> chapter attributes to provide the necessary behavior of request
sending (delay, limitation of a submit and render area, requests frequency, and etc.). For
detailed information on these attributes see again the <emphasis
role="bold">
+ <property><ulink
url="ch06s05.html"><a4j:support></ulink></property></emphasis>
component description.
+ </para>
+ </section>
+</chapter>
\ No newline at end of file
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/region.xml
===================================================================
--- trunk/docs/userguide/en/included/region.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/region.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,114 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <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.ajax.AjaxRegion</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>org.ajax4jsf.components.AjaxRegion.</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.HtmlAjaxRegion</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.components.AjaxRegionRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>Here is an example of the region decoding on a page. </para>
- <programlisting role="XML"><![CDATA[<a4j:region>
-<!--..Some content that will be decoded on server after Ajax request.-->
-<a4j:region>]]></programlisting>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxRegion;
-HtmlAjaxRegion = newRegion new HtmlAjaxRegion();
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>The region is a component used for manipulation with components sent to
the server. It sets particular processing parameters for an area on the server, i.e. the
region deals with data input on the server and has no direct impact on output. To read
more on the components responsible for out, see "reference"
-</para>
- <para>The region marks an area page that is decoded on the server. In most
cases it is not necessary to use the region, as ViewRoot is a default region. This
component helps to reduce data quantity processed by the server, but the region
doesn't influence on the standard submission rules. It means
that:<itemizedlist>
- <listitem>
- The area that is to be submitted onto the server should be embedded in
<emphasis role="bold">
-<property><h:form/a4j:form></property>
-</emphasis> component.
- </listitem>
- <listitem>
- The whole form is submitted on Ajax response and not a region the request is
performed from.
- </listitem>
- </itemizedlist></para>
- <para><emphasis
role="bold">Example:</emphasis></para>
- <programlisting role="XML"><![CDATA[<h:form
id="form1">
- <a4j:region>
- <a4j:commandLink reRender="someID" value="Link"
id="link1"/>
- <!--..Some content that will be decoded on server after Ajax request.-->
- </a4j:region>
-<h:form>]]></programlisting>
- <para>Hence, the <emphasis role="bold">
- <property><a4j:commandLink></property>
- </emphasis> request generation causes full "form1" form
submission onto the server, the only difference is that a component tree part decoded on
the serve is the part included into the region.</para>
- <para>The regions could be nested in any order, the server picks out and
decodes only the region, which contains a particular component that sends a
request.</para>
- <para><emphasis
role="bold">Example:</emphasis></para>
- <programlisting role="XML"><![CDATA[<a4j:region>
-<a4j:commandLink reRender="someID" value="Link"
id="link1"/>
-<a4j:region>
-<a4j:commandLink reRender="someID" value="Link"
id="link2"/>
-<!--..Some content that will be decoded on server after Ajax request.-->
-</a4j:region >
-<!--..Some content that will be decoded on server after Ajax request.-->
-</a4j:region >]]></programlisting>
- <para>Therefore, the external region is decoded for the
"link1" and the internal one is decoded for the
"link2".</para>
- <para>Ajax4jsf allows setting Ajax responses rendering directly basing on
component tree nodes without referring to the JSP (XHTML) page code. It could be defined
by selfRendered attribute setting to "true" on <emphasis
role="bold">
- <property><a4j:region></property>
- </emphasis> and could help considerably speed up a response output. However,
this rapid processing could cause missing of transient components that present on view and
don't come into a component tree as well as omitting of <emphasis
role="bold">
- <property><a4j:outputPanel></property>
- </emphasis> usage described below.
-</para>
- <para><emphasis
role="bold">Example:</emphasis></para>
- <programlisting role="XML"><![CDATA[<a4j:region selfRendered
="true">
-<a4j:commandLink reRender="someID" value="Link"
id="link1"/>
-<!--..Some content with HTML used ("br" ,"h1" and other tags
used)-->
-</a4j:region >]]></programlisting>
- <para>In this case, the processing is quicker and going on without referring to
a page code, but the HTML code that isn't saved in a component tree could be lost.
Thus this optimization should be very carefully performed and a usage of the additional
components ajax4jsf (<emphasis
role="bold"><property><a4j:outputPanel></property></emphasis>)
is required. </para>
- <para>The processing could be also accelerated if a region decoded for the
processing passes straight away into Encode. But to update some data out of the region or
on another region, use the <emphasis role="italic">
- <property>"renderRegionOnly"</property>
- </emphasis>
-attribute set to "false" ("true on default") to
change this behaviour.</para>
- <para><emphasis
role="bold">Example:</emphasis></para>
- <programlisting role="XML"><![CDATA[<a4j:region
renderRegionOnly ="true">
-<a4j:commandLink reRender="someID2" value="Link1"
id="link1"/>
-<h:panelGroup id="someId1">
-<h:panelGroup>
-</a4j:region >
-<a4j:region renderRegionOnly="false">
-<a4j:commandLink reRender="someID1" value="Link2"
id="link2"/>
-<h:panelGroup id="someId1">
-<h:panelGroup>
-</a4j:region >]]></programlisting>
- <para>This example shows that one of the regions is decoded when a link is used
inside. Nevertheless,
- if after processing the "link1" is clicked, the first region passes
into Encode as a root
- region and encode performance time is reduced. This optimization doesn't
allow data update out of the
- region and should be implemented very carefully. The data out of the region
described with "renderRegionOnly"="false" is updated
successfully.</para>
- </section>
-</chapter>
Copied: tags/1_1_1_rc1/docs/userguide/en/included/region.xml (from rev 163,
trunk/docs/userguide/en/included/region.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/region.xml (rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/region.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,116 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <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.ajax.AjaxRegion</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>org.ajax4jsf.components.AjaxRegion.</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.HtmlAjaxRegion</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.components.AjaxRegionRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>Here is an example of the region decoding on a page. </para>
+ <programlisting role="XML"><![CDATA[<a4j:region>
+ <!--..Some content that will be decoded on server after Ajax request.-->
+</a4j:region>]]></programlisting>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxRegion;
+...
+HtmlAjaxRegion newRegion = new HtmlAjaxRegion();
+...
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>The region is a component used for manipulation with components sent to
the server. It sets particular processing parameters for an area on the server, i.e. the
region deals with data input on the server and has no direct impact on output. To read
more on the components responsible for out, see "reference"
+</para>
+ <para>The region marks an area page that is decoded on the server. In most
cases it is not necessary to use the region, as ViewRoot is a default region. This
component helps to reduce data quantity processed by the server, but the region
doesn't influence on the standard submission rules. It means
that:<itemizedlist>
+ <listitem>
+ The area that is to be submitted onto the server should be embedded in
<emphasis role="bold">
+<property><h:form/a4j:form></property>
+</emphasis> component.
+ </listitem>
+ <listitem>
+ The whole form is submitted on Ajax response and not a region the request is
performed from.
+ </listitem>
+ </itemizedlist></para>
+ <para><emphasis
role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<h:form
id="form1">
+ <a4j:region>
+ <a4j:commandLink reRender="someID" value="Link"
id="link1"/>
+ <!--..Some content that will be decoded on server after Ajax request.-->
+ </a4j:region>
+<h:form>]]></programlisting>
+ <para>Hence, the <emphasis role="bold">
+ <property><a4j:commandLink></property>
+ </emphasis> request generation causes full "form1" form
submission onto the server, the only difference is that a component tree part decoded on
the serve is the part included into the region.</para>
+ <para>The regions could be nested in any order, the server picks out and
decodes only the region, which contains a particular component that sends a
request.</para>
+ <para><emphasis
role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<a4j:region>
+ <a4j:commandLink reRender="someID" value="Link"
id="link1"/>
+ <a4j:region>
+ <a4j:commandLink reRender="someID" value="Link"
id="link2"/>
+ <!--..Some content that will be decoded on server after Ajax request.-->
+ </a4j:region >
+ <!--..Some content that will be decoded on server after Ajax request.-->
+</a4j:region >]]></programlisting>
+ <para>Therefore, the external region is decoded for the
"link1" and the internal one is decoded for the
"link2".</para>
+ <para>Ajax4jsf allows setting Ajax responses rendering directly basing on
component tree nodes without referring to the JSP (XHTML) page code. It could be defined
by selfRendered attribute setting to "true" on <emphasis
role="bold">
+ <property><a4j:region></property>
+ </emphasis> and could help considerably speed up a response output. However,
this rapid processing could cause missing of transient components that present on view and
don't come into a component tree as well as omitting of <emphasis
role="bold">
+ <property><a4j:outputPanel></property>
+ </emphasis> usage described below.
+</para>
+ <para><emphasis
role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<a4j:region selfRendered
="true">
+ <a4j:commandLink reRender="someID" value="Link"
id="link1"/>
+ <!--..Some content with HTML used ("br" ,"h1" and other tags
used)-->
+</a4j:region >]]></programlisting>
+ <para>In this case, the processing is quicker and going on without referring to
a page code, but the HTML code that isn't saved in a component tree could be lost.
Thus this optimization should be very carefully performed and a usage of the additional
components ajax4jsf (<emphasis
role="bold"><property><a4j:outputPanel></property></emphasis>)
is required. </para>
+ <para>The processing could be also accelerated if a region decoded for the
processing passes straight away into Encode. But to update some data out of the region or
on another region, use the <emphasis role="italic">
+ <property>"renderRegionOnly"</property>
+ </emphasis>
+attribute set to "false" ("true on default") to
change this behaviour.</para>
+ <para><emphasis
role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<a4j:region
renderRegionOnly="true">
+ <a4j:commandLink reRender="someID2" value="Link1"
id="link1"/>
+ <h:panelGroup id="someId1">
+ </h:panelGroup>
+</a4j:region>
+<a4j:region renderRegionOnly="false">
+ <a4j:commandLink reRender="someID1" value="Link2"
id="link2"/>
+ <h:panelGroup id="someId1">
+ </h:panelGroup>
+</a4j:region>]]></programlisting>
+ <para>This example shows that one of the regions is decoded when a link is used
inside. Nevertheless,
+ if after processing the "link1" is clicked, the first region passes
into Encode as a root
+ region and encode performance time is reduced. This optimization doesn't
allow data update out of the
+ region and should be implemented very carefully. The data out of the region
described with "renderRegionOnly"="false" is updated
successfully.</para>
+ </section>
+</chapter>
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/repeat.xml
===================================================================
--- trunk/docs/userguide/en/included/repeat.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/repeat.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,114 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <para><table frame="all">
- <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.ajax.Repeat </entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>javax.faces.Data </entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.HtmlAjaxRepeat </entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.components.RepeatRenderer </entry>
- </row>
- </tbody>
- </tgroup>
- </table></para>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>The component definition on a page is the same as for the <emphasis
role="italic">
- <property>"facelets"</property>
- </emphasis> component:</para>
- <programlisting role="XML"><![CDATA[<a4j:repeat
id="detail" value="#{bean.props}" var="detail">
- <h:outputText value="#{detail.someProperty}">
-</a4j:repeat>]]></programlisting>
- <para>The output is generated according to a collection contained in
<emphasis role="italic">
- <property>"bean.props"</property>
- </emphasis> with the "detail" key passed to child
components.</para>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxRepeat;
-...
-HtmlAjaxRepeat repeater = new HtmlAjaxRepeat ();
-...
-]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>The main difference of this component from iterative components of
other libraries is a special <emphasis role="italic">
- <property>"ajaxKeys"</property>
- </emphasis> attribute. This attribute defines strings that are updated after
an AJAX request. As a result it becomes easier to update several child components
separately without updating the whole page.</para>
- <programlisting role="JSP"><![CDATA[<a4j:poll
intervall="1000" action="#{repeater.action}"
reRender="list">
-...
-<table>
- <tbody>
- <a4j:repeat value="#{bean.props}" var="detail"
binding="#{repeater.myRepeat}"
- id="list" ajaxKeys="#{repeater.ajaxedRowsSet}">
- </tr>
- <td>
- <h:outputText value="detail.someProperty">
- </td>
- </tr>
- </a4j:repeat>
- <tbody>
-<table>
-]]></programlisting>
- <para>Thus, a list with a table structure from <emphasis
role="italic">
- <property>"bean.props"</property>
- </emphasis> is output.</para>
- <para>In the above-mentioned example the component <emphasis
role="bold">
- <property><a4j:poll></property>
- </emphasis> sends AJAX requests every second, calling the <emphasis
role="italic">
- <property>"action"</property>
- </emphasis> method of the <emphasis role="italic">
- <property>"repeater"</property>
- </emphasis> bean.
- </para>
- <note>
- <title>Note:</title>
- <para>The <emphasis role="bold">
- <property><a4j:repeater></property>
- </emphasis> component is defined as fully updated, but really updated there
are only the strings which rowKeys are included into the set <emphasis
role="italic">
- <property>"ajaxRowSet"</property>
- </emphasis> defined in the <emphasis role="italic">
- <property>"ajaxKeys"</property>
- </emphasis> attribute </para>
- <para>The set could be defined during the action method processing using data
on a model from the property <emphasis role="italic">
- <property>"repeater.myRepeat"</property>
- </emphasis></para>
- </note>
-<para>One more benefit of this component is absence of strictly defined markup as
JSF HTML DataTable and Tomahawk DataTable has, hence the components could be used more
flexibly anywhere where it's necessary to output the results of selection from some
collection.</para>
-<para>The next example shows collection output as a plain HTML list</para>
- <programlisting role="JSP"><![CDATA[<ul>
- <a4j:repeat ...>
- <li>...<li/>
- ...
- <li>...<li/>
- </a4j:repeat>
-</ul>
-]]></programlisting>
- <para>All other general attributes are defined according to the similar
attributes of iterative components (<emphasis role="bold">
- <property><h:dataTable></property>
- </emphasis> or <emphasis role="bold">
- <property><ui:repeat></property>
- </emphasis>) and are used in the same way.</para>
- </section>
-</chapter>
\ No newline at end of file
Copied: tags/1_1_1_rc1/docs/userguide/en/included/repeat.xml (from rev 163,
trunk/docs/userguide/en/included/repeat.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/repeat.xml (rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/repeat.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,114 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <para><table frame="all">
+ <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.ajax.Repeat </entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>javax.faces.Data </entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.HtmlAjaxRepeat </entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.components.RepeatRenderer </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>The component definition on a page is the same as for the <emphasis
role="italic">
+ <property>"facelets"</property>
+ </emphasis> component:</para>
+ <programlisting role="XML"><![CDATA[<a4j:repeat
id="detail" value="#{bean.props}" var="detail">
+ <h:outputText value="#{detail.someProperty}"/>
+</a4j:repeat>]]></programlisting>
+ <para>The output is generated according to a collection contained in
<emphasis role="italic">
+ <property>"bean.props"</property>
+ </emphasis> with the "detail" key passed to child
components.</para>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxRepeat;
+...
+HtmlAjaxRepeat repeater = new HtmlAjaxRepeat ();
+...
+]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>The main difference of this component from iterative components of
other libraries is a special <emphasis role="italic">
+ <property>"ajaxKeys"</property>
+ </emphasis> attribute. This attribute defines strings that are updated after
an AJAX request. As a result it becomes easier to update several child components
separately without updating the whole page.</para>
+ <programlisting role="JSP"><![CDATA[<a4j:poll
intervall="1000" action="#{repeater.action}"
reRender="list">
+...
+<table>
+ <tbody>
+ <a4j:repeat value="#{bean.props}" var="detail"
binding="#{repeater.myRepeat}"
+ id="list" ajaxKeys="#{repeater.ajaxedRowsSet}">
+ </tr>
+ <td>
+ <h:outputText value="detail.someProperty">
+ </td>
+ </tr>
+ </a4j:repeat>
+ <tbody>
+<table>
+]]></programlisting>
+ <para>Thus, a list with a table structure from <emphasis
role="italic">
+ <property>"bean.props"</property>
+ </emphasis> is output.</para>
+ <para>In the above-mentioned example the component <emphasis
role="bold">
+ <property><a4j:poll></property>
+ </emphasis> sends AJAX requests every second, calling the <emphasis
role="italic">
+ <property>"action"</property>
+ </emphasis> method of the <emphasis role="italic">
+ <property>"repeater"</property>
+ </emphasis> bean.
+ </para>
+ <note>
+ <title>Note:</title>
+ <para>The <emphasis role="bold">
+ <property><a4j:repeater></property>
+ </emphasis> component is defined as fully updated, but really updated there
are only the strings which rowKeys are included into the set <emphasis
role="italic">
+ <property>"ajaxRowSet"</property>
+ </emphasis> defined in the <emphasis role="italic">
+ <property>"ajaxKeys"</property>
+ </emphasis> attribute </para>
+ <para>The set could be defined during the action method processing using data
on a model from the property <emphasis role="italic">
+ <property>"repeater.myRepeat"</property>
+ </emphasis></para>
+ </note>
+<para>One more benefit of this component is absence of strictly defined markup as
JSF HTML DataTable and Tomahawk DataTable has, hence the components could be used more
flexibly anywhere where it's necessary to output the results of selection from some
collection.</para>
+<para>The next example shows collection output as a plain HTML list</para>
+ <programlisting role="JSP"><![CDATA[<ul>
+ <a4j:repeat ...>
+ <li>...<li/>
+ ...
+ <li>...<li/>
+ </a4j:repeat>
+</ul>
+]]></programlisting>
+ <para>All other general attributes are defined according to the similar
attributes of iterative components (<emphasis role="bold">
+ <property><h:dataTable></property>
+ </emphasis> or <emphasis role="bold">
+ <property><ui:repeat></property>
+ </emphasis>) and are used in the same way.</para>
+ </section>
+</chapter>
\ No newline at end of file
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/status.xml
===================================================================
--- trunk/docs/userguide/en/included/status.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/status.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,115 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <para><table frame="all">
- <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.ajax.Status </entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>javax.faces.Panel </entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.HtmlAjaxStatus </entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.components.AjaxStatusRenderer </entry>
- </row>
- </tbody>
- </tgroup>
- </table></para>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>There are two ways to define elements indicating a request status
:</para>
- <itemizedlist>
- <listitem>
- With <emphasis role="italic">
-
<property>"StartText"/"StopText"</property>
- </emphasis> atributes:
- <programlisting role="XML"><![CDATA[<a4j:status
startText="Progress" stopText="Done"
for="stat1">]]></programlisting>
- <para>In this case, text elements for the corresponding status are
generated.</para>
- </listitem>
- </itemizedlist>
- <itemizedlist>
- <listitem>
- With "Start"/"Stop" facets definition:
- <programlisting role="XML"><![CDATA[<a4j:status
for="stat2">
- <f:facet name="start">
- <h:graphicImage value="ajax_process.gif" />
- </f:facet>
- <f:facet name="stop">
- <h:graphicImage value="ajax_stoped.gif" />
- </f:facet>
-</a4j:status>]]></programlisting>
- <para>In this case, the elements are generated for each status and
correspond the facets content.</para>
- </listitem>
- </itemizedlist>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxStatus;
-...
-HtmlAjaxStatus myStatus = new org.ajax4jsf.ajax.html.HtmlAjaxStatus();
-...]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>There are two ways for components or containers definition, which AJAX
requests status is tracked by a component.<itemizedlist>
- <listitem>
- Definition with the <emphasis role="italic">
- <property>"for"</property>
- </emphasis>
-attribute on the <emphasis role="bold">
- <property><a4j:status></property>
- </emphasis> component. Here <emphasis role="italic">
- <property>"for"</property>
- </emphasis>
-attribute should point at an AJAX container (<emphasis
role="bold"><property><a4j:region></property></emphasis>)
"id", which requests are tracked by a component.
- </listitem>
- </itemizedlist><itemizedlist>
- <listitem>
- Definition with the <emphasis role="italic">
- <property>"status"</property>
- </emphasis>
-attribute obtained by any Ajax4jsf library action component. The attribute should point
at the <emphasis role="bold">
- <property><a4j:status></property>
- </emphasis> component "id". Then this <emphasis
role="bold">
- <property><a4j:status></property>
- </emphasis> component shows the status for the request fired from this
action component.
- </listitem>
- </itemizedlist></para>
- <para>The component creates two <emphasis
role="bold"><property><span></property></emphasis>
elements with content defined for each status, one of the elements (start) is initially
hidden. At the beginning of an AJAX request, elements state is inversed, hence the second
element is shown and the first is hidden. At the end of a response processing, elements
display states return to its initial values.</para>
- <para>Example:</para>
- <programlisting role="XML"><![CDATA[<a4j:status
startText="Started" stopText="stopped"
layout="block"/>]]></programlisting>
- <para>is decoded on a page as:</para><programlisting
role="XML"><![CDATA[<span id="j_id20:status.start"
style="display: none">
- Started
-</span>
-<span id="j_id20:status.stop">
- Stopped
-</span>]]></programlisting>
- <para>And after the generation of an AJAX response is changed
to:</para>
- <programlisting role="XML"><![CDATA[<span
id="j_id20:status.start">
- Started
-</span>
-<span id="j_id20:status.stop" style="display: none">
- Stopped
-</span>]]></programlisting>
- <para>There is a possibility to group a <emphasis
role="bold"><property><a4j:status></property></emphasis>
elements content into <emphasis
role="bold"><property><div></property></emphasis>
elements, instead of <emphasis
role="bold"><property><span></property></emphasis>.
To use it, just redefine the <emphasis role="italic">
- <property>"layout"</property>
- </emphasis>
-attribute from "incline"(default) to
"block".</para>
- </section>
-</chapter>
Copied: tags/1_1_1_rc1/docs/userguide/en/included/status.xml (from rev 163,
trunk/docs/userguide/en/included/status.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/status.xml (rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/status.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,115 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <para><table frame="all">
+ <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.ajax.Status </entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>javax.faces.Panel </entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.HtmlAjaxStatus </entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.components.AjaxStatusRenderer </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>There are two ways to define elements indicating a request status
:</para>
+ <itemizedlist>
+ <listitem>
+ With <emphasis role="italic">
+
<property>"StartText"/"StopText"</property>
+ </emphasis> atributes:
+ <programlisting role="XML"><![CDATA[<a4j:status
startText="Progress" stopText="Done"
for="stat1">]]></programlisting>
+ <para>In this case, text elements for the corresponding status are
generated.</para>
+ </listitem>
+ </itemizedlist>
+ <itemizedlist>
+ <listitem>
+ With "Start"/"Stop" facets definition:
+ <programlisting role="XML"><![CDATA[<a4j:status
for="stat2">
+ <f:facet name="start">
+ <h:graphicImage value="ajax_process.gif" />
+ </f:facet>
+ <f:facet name="stop">
+ <h:graphicImage value="ajax_stoped.gif" />
+ </f:facet>
+</a4j:status>]]></programlisting>
+ <para>In this case, the elements are generated for each status and
correspond the facets content.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxStatus;
+...
+HtmlAjaxStatus myStatus = new HtmlAjaxStatus();
+...]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>There are two ways for components or containers definition, which AJAX
requests status is tracked by a component.<itemizedlist>
+ <listitem>
+ Definition with the <emphasis role="italic">
+ <property>"for"</property>
+ </emphasis>
+attribute on the <emphasis role="bold">
+ <property><a4j:status></property>
+ </emphasis> component. Here <emphasis role="italic">
+ <property>"for"</property>
+ </emphasis>
+attribute should point at an AJAX container (<emphasis
role="bold"><property><a4j:region></property></emphasis>)
"id", which requests are tracked by a component.
+ </listitem>
+ </itemizedlist><itemizedlist>
+ <listitem>
+ Definition with the <emphasis role="italic">
+ <property>"status"</property>
+ </emphasis>
+attribute obtained by any Ajax4jsf library action component. The attribute should point
at the <emphasis role="bold">
+ <property><a4j:status></property>
+ </emphasis> component "id". Then this <emphasis
role="bold">
+ <property><a4j:status></property>
+ </emphasis> component shows the status for the request fired from this
action component.
+ </listitem>
+ </itemizedlist></para>
+ <para>The component creates two <emphasis
role="bold"><property><span></property></emphasis>
elements with content defined for each status, one of the elements (start) is initially
hidden. At the beginning of an AJAX request, elements state is inversed, hence the second
element is shown and the first is hidden. At the end of a response processing, elements
display states return to its initial values.</para>
+ <para>Example:</para>
+ <programlisting role="XML"><![CDATA[<a4j:status
startText="Started" stopText="stopped"
layout="block"/>]]></programlisting>
+ <para>is decoded on a page as:</para><programlisting
role="XML"><![CDATA[<span id="j_id20:status.start"
style="display: none">
+ Started
+</span>
+<span id="j_id20:status.stop">
+ Stopped
+</span>]]></programlisting>
+ <para>And after the generation of an AJAX response is changed
to:</para>
+ <programlisting role="XML"><![CDATA[<span
id="j_id20:status.start">
+ Started
+</span>
+<span id="j_id20:status.stop" style="display: none">
+ Stopped
+</span>]]></programlisting>
+ <para>There is a possibility to group a <emphasis
role="bold"><property><a4j:status></property></emphasis>
elements content into <emphasis
role="bold"><property><div></property></emphasis>
elements, instead of <emphasis
role="bold"><property><span></property></emphasis>.
To use it, just redefine the <emphasis role="italic">
+ <property>"layout"</property>
+ </emphasis>
+attribute from "incline"(default) to
"block".</para>
+ </section>
+</chapter>
Deleted: tags/1_1_1_rc1/docs/userguide/en/included/support.xml
===================================================================
--- trunk/docs/userguide/en/included/support.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/included/support.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,148 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter>
- <section>
- <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.ajax.Support</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>org.ajax4jsf.components.AjaxSupport</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.ajax.html.HtmlAjaxSupport</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.components.AjaxSupportRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section>
- <title>Creating on a page</title>
- <para>To use a component, place <emphasis role="bold">
- <property><a4j:support></property>
- </emphasis> as nested to the component requesting AJAX functionality and
specify an event of a
- parent component that generates AJAX request and the components to be rerendered
after a response
- from the server.</para>
- <para><emphasis
role="bold">Example:</emphasis></para>
- <programlisting role="XML"><![CDATA[<h:inputText
value="#{bean.text}">
-<a4j:support event="onkeyup" reRender="repeater"/>
-</h:inputText>
-<h:outputText id="repeater"
value="#{bean.text}"/>]]></programlisting>
- <para>On every keyup event generated by an input field, form is submitted on
the server via Ajax and
- on a response coming from the server, element with "repeater" id,
founded in a DOM tree is
- redrawn according to a new data from the response.</para>
- </section>
- <section>
- <title>Dynamical creation of a component from Java code</title>
- <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxSupport;
-HtmlAjaxSupport mySupport = new org.ajax4jsf.ajax.html.HtmlAjaxSupport
();>]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para>A4j support addition is very similar to correspondent event redefinition
of a component, i.e.
-</para>
- <para><emphasis
role="bold">Example:</emphasis></para>
- <programlisting role="XML"><![CDATA[<h:inputText
value="#{bean.text}">
- <a4j:support event="onkeyup" reRender="repeater"/>
-</h:inputText>
-]]></programlisting>
-<para>Is decoded on the page as:</para>
-<programlisting role="XML"><![CDATA[
-<input onkeyup="A4J.AJAX.Submit( Some request parameters )"/>
-]]></programlisting>
- <para>As you see from the code, the "onkeyup"
-event calls a utility ajax4jsf method that submit a form creating a special marks for a
filter informing that it is an Ajax request. Thus, any supports quantity could be added
to every component, the supports define component behavior on these events. </para>
- <note>
- <para>The components: <emphasis
role="bold"><property><a4j:commandLink></property></emphasis>,
<emphasis
role="bold"><property><a4j:commandButton></property></emphasis>,
<emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> and others from Ajax4jsf library are already supplied with
<emphasis role="bold">
- <property><a4j:support></property>
- </emphasis> functionality and there is no necessity to add the support to
them. </para>
- </note>
- <para>With the help of <emphasis role="italic">
- <property>"onsubmit"</property></emphasis>
and <emphasis role="italic">
- <property>"oncomplete"</property></emphasis>
attributes the component allows using JavaScript before (for request sending conditions
checking) and after AJAX response processing termination (for performance of user-defined
activities on the client) </para>
- <para><emphasis
role="bold">Example:</emphasis></para>
- <programlisting role="XML"><![CDATA[<h:selectOneMenu
value="#{bean.text}">
-<f:selectItem itemValue="First Item " itemLabel="First Item"/>
-<f:selectItem itemValue=" Second Item " itemLabel="Second
Item"/>
-<f:selectItem itemValue=" Third Item " itemLabel="Third
Item"/>
- <a4j:support event="onblur" reRender="panel"
- onsubmit="if(!confirm('Are you sure to change the option ?'))
- {form.reset(); return false;}"
- oncomplete="alert('Value succesfully stored')"/>
-</h:selectOneMenu>]]></programlisting>
- <para>In example there is the condition checking (confirm) is used before
request sending and message printing after the request processing is over. </para>
- <para>The components allows different AJAX request managing ways for its
various optimization in particular conditions such as:
-<itemizedlist>
- <listitem>
- <emphasis role="bold">Limitation of the submit area and
updating area for the request.</emphasis>
- <para><emphasis
role="italic"><property>"ajaxSingle"</property></emphasis>
is an attribute that allows submission on the server only component sending a request, as
if the component presented on a separate form.
-
-</para>
- <para><emphasis
role="italic"><property>"limitToList"</property></emphasis>
is an attribute that allows to limit areas, which are updated after the responses. Only
these components defined in the reRender attribute are updated. </para>
- </listitem>
- </itemizedlist></para>
- <para><emphasis role="bold">Example
1:</emphasis></para>
- <programlisting role="XML"><![CDATA[<h:form>
-<h:inputText value="#{person.name}" >
-<a4j:support event="onkeyup" reRender="test"
ajaxSingle="true"/>
-</h:inputText>
-<h:inputText value="#{person.middleName}"/>
-</form>]]></programlisting>
- <para>In this example the request contains only the input component causes the
request generation, not all the components contained on a form, because of
"ajaxSingle=true" usage. </para>
- <para><emphasis role="bold">Example
2:</emphasis></para>
- <programlisting role="XML"><![CDATA[<h:form>
-<a4j:outputPanel ajaxRendered="true">
-<h:messages/>
-</a4j:outputPanel>
-<h:inputText value="#{person.name}">
-<a4j:support event="onkeyup" reRender="test"
- limitToList="true"/>
-</h:inputText>
-<h:outputText value="#{person.name}" id="test"/>
-</form>]]></programlisting>
- <para>In this example the component "h:messages" is always
updated (as it capturing all AJAX requests, located in ajaxRendered <emphasis
role="bold"><property><a4j:outputPanel></property></emphasis>),
except the case when a response is sent from the input component from the example. On
sending this component marks that updating area is limited to the defined in it
components, it means that on its usage with
"limitToList"="true" the only component updated is
the one with "d"="test".</para>
- <itemizedlist>
- <listitem>
- <emphasis role="bold">Limitation of requests frequency and
updates quantity after the responses. </emphasis>
- <para><emphasis
role="italic"><property>"requestDelay"</property></emphasis>
is an attribute that defines a time interval in seconds minimally permissible between
responses.
-
-</para>
- <para><emphasis
role="italic"><property>"eventQueue"</property></emphasis>
is an attribute for naming of the queue where the next response is kept in till its
processing, but if the next event comes in till this time, the waiting event is taken
away, replacing with a new one.
-
-</para>
- <para><emphasis
role="italic"><property>"ignoreDupResponces"</property></emphasis>
is an attribute that allows to disable any updates on the client after an AJAX request if
another AJAX request is already sent.
-</para>
- <para><emphasis
role="italic"><property>"timeout"</property></emphasis>
is an attribute that allows to set a time interval in millisecond to define a maximum time
period of response wait time. In case of the interval interaction, a new request is sent
and the previous one is canceled. Postprocessing of a response isn't performed.
-</para>
- <para><emphasis
role="bold">Example:</emphasis></para>
- <programlisting role="XML"><![CDATA[<h:form>
-<h:inputText value="#{person.name}">
- <a4j:support event="onkeyup" reRender="test"
- requestDelay="1000" ignoreDupResponces="true"
eventsQueue="myQueue"/>
-</h:inputText>
-<h:outputText value="#{person.name}" id="test"/>
-</form>]]></programlisting>
- <para>This example clearly shows mentioned above attributes. If quick
typing in a text field happens, every next requests sending is delayed for a second and
requests quantity is reduced. The requests are kept in the queue
"myQueue" till its the sending.
-Moreover, if the next request is already sent, the rerendering after the previous request
is banned, and
- it helps to avoid unnecessary processing on the client.</para>
- </listitem>
- </itemizedlist>
- </section>
- </chapter>
\ No newline at end of file
Copied: tags/1_1_1_rc1/docs/userguide/en/included/support.xml (from rev 163,
trunk/docs/userguide/en/included/support.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/included/support.xml (rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/included/support.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,146 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <section>
+ <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.ajax.Support</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>org.ajax4jsf.components.AjaxSupport</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.ajax.html.HtmlAjaxSupport</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.components.AjaxSupportRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ <section>
+ <title>Creating on a page</title>
+ <para>To use a component, place <emphasis role="bold">
+ <property><a4j:support></property>
+ </emphasis> as nested to the component requesting AJAX functionality and
specify an event of a
+ parent component that generates AJAX request and the components to be rerendered
after a response
+ from the server.</para>
+ <para><emphasis
role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<h:inputText
value="#{bean.text}">
+ <a4j:support event="onkeyup" reRender="repeater"/>
+</h:inputText>
+<h:outputText id="repeater"
value="#{bean.text}"/>]]></programlisting>
+ <para>On every keyup event generated by an input field, form is submitted on
the server via Ajax and
+ on a response coming from the server, element with "repeater" id,
founded in a DOM tree is
+ redrawn according to a new data from the response.</para>
+ </section>
+ <section>
+ <title>Dynamical creation of a component from Java code</title>
+ <programlisting role="JAVA"><![CDATA[import
org.ajax4jsf.ajax.html.HtmlAjaxSupport;
+...
+HtmlAjaxSupport mySupport = new HtmlAjaxSupport();>]]></programlisting>
+ </section>
+ <section>
+ <title>Key attributes and ways of usage</title>
+ <para>A4j support addition is very similar to correspondent event redefinition
of a component, i.e.
+</para>
+ <para><emphasis
role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<h:inputText
value="#{bean.text}">
+ <a4j:support event="onkeyup" reRender="repeater"/>
+</h:inputText>
+]]></programlisting>
+<para>Is decoded on the page as:</para>
+<programlisting role="XML"><![CDATA[
+<input onkeyup="A4J.AJAX.Submit( Some request parameters )"/>
+]]></programlisting>
+ <para>As you see from the code, the "onkeyup"
+event calls a utility ajax4jsf method that submit a form creating a special marks for a
filter informing that it is an Ajax request. Thus, any supports quantity could be added
to every component, the supports define component behavior on these events. </para>
+ <note>
+ <para>The components: <emphasis
role="bold"><property><a4j:commandLink></property></emphasis>,
<emphasis
role="bold"><property><a4j:commandButton></property></emphasis>,
<emphasis role="bold">
+ <property><a4j:poll></property>
+ </emphasis> and others from Ajax4jsf library are already supplied with
<emphasis role="bold">
+ <property><a4j:support></property>
+ </emphasis> functionality and there is no necessity to add the support to
them. </para>
+ </note>
+ <para>With the help of <emphasis role="italic">
+ <property>"onsubmit"</property></emphasis>
and <emphasis role="italic">
+ <property>"oncomplete"</property></emphasis>
attributes the component allows using JavaScript before (for request sending conditions
checking) and after AJAX response processing termination (for performance of user-defined
activities on the client) </para>
+ <para><emphasis
role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<h:selectOneMenu
value="#{bean.text}">
+ <f:selectItem itemValue="First Item " itemLabel="First
Item"/>
+ <f:selectItem itemValue=" Second Item " itemLabel="Second
Item"/>
+ <f:selectItem itemValue=" Third Item " itemLabel="Third
Item"/>
+ <a4j:support event="onblur" reRender="panel"
onsubmit="if(!confirm('Are you sure to change the option ?'))
+ {form.reset(); return false;}" oncomplete="alert('Value succesfully
stored')"/>
+</h:selectOneMenu>]]></programlisting>
+ <para>In example there is the condition checking (confirm) is used before
request sending and message printing after the request processing is over. </para>
+ <para>The components allows different AJAX request managing ways for its
various optimization in particular conditions such as:
+<itemizedlist>
+ <listitem>
+ <emphasis role="bold">Limitation of the submit area and
updating area for the request.</emphasis>
+ <para><emphasis
role="italic"><property>"ajaxSingle"</property></emphasis>
is an attribute that allows submission on the server only component sending a request, as
if the component presented on a separate form.
+
+</para>
+ <para><emphasis
role="italic"><property>"limitToList"</property></emphasis>
is an attribute that allows to limit areas, which are updated after the responses. Only
these components defined in the reRender attribute are updated. </para>
+ </listitem>
+ </itemizedlist></para>
+ <para><emphasis role="bold">Example
1:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<h:form>
+ <h:inputText value="#{person.name}">
+ <a4j:support event="onkeyup" reRender="test"
ajaxSingle="true"/>
+ </h:inputText>
+ <h:inputText value="#{person.middleName}"/>
+</form>]]></programlisting>
+ <para>In this example the request contains only the input component causes the
request generation, not all the components contained on a form, because of
"ajaxSingle=true" usage. </para>
+ <para><emphasis role="bold">Example
2:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<h:form>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:messages/>
+ </a4j:outputPanel>
+ <h:inputText value="#{person.name}">
+ <a4j:support event="onkeyup" reRender="test"
limitToList="true"/>
+ </h:inputText>
+ <h:outputText value="#{person.name}" id="test"/>
+</form>]]></programlisting>
+ <para>In this example the component "h:messages" is always
updated (as it capturing all AJAX requests, located in ajaxRendered <emphasis
role="bold"><property><a4j:outputPanel></property></emphasis>),
except the case when a response is sent from the input component from the example. On
sending this component marks that updating area is limited to the defined in it
components, it means that on its usage with
"limitToList"="true" the only component updated is
the one with "d"="test".</para>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="bold">Limitation of requests frequency and
updates quantity after the responses. </emphasis>
+ <para><emphasis
role="italic"><property>"requestDelay"</property></emphasis>
is an attribute that defines a time interval in seconds minimally permissible between
responses.
+
+</para>
+ <para><emphasis
role="italic"><property>"eventQueue"</property></emphasis>
is an attribute for naming of the queue where the next response is kept in till its
processing, but if the next event comes in till this time, the waiting event is taken
away, replacing with a new one.
+
+</para>
+ <para><emphasis
role="italic"><property>"ignoreDupResponces"</property></emphasis>
is an attribute that allows to disable any updates on the client after an AJAX request if
another AJAX request is already sent.
+</para>
+ <para><emphasis
role="italic"><property>"timeout"</property></emphasis>
is an attribute that allows to set a time interval in millisecond to define a maximum time
period of response wait time. In case of the interval interaction, a new request is sent
and the previous one is canceled. Postprocessing of a response isn't performed.
+</para>
+ <para><emphasis
role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[<h:form>
+ <h:inputText value="#{person.name}">
+ <a4j:support event="onkeyup" reRender="test"
+ requestDelay="1000" ignoreDupResponces="true"
eventsQueue="myQueue"/>
+ </h:inputText>
+ <h:outputText value="#{person.name}" id="test"/>
+</form>]]></programlisting>
+ <para>This example clearly shows mentioned above attributes. If quick
typing in a text field happens, every next requests sending is delayed for a second and
requests quantity is reduced. The requests are kept in the queue
"myQueue" till its the sending.
+Moreover, if the next request is already sent, the rerendering after the previous request
is banned, and
+ it helps to avoid unnecessary processing on the client.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+ </chapter>
\ No newline at end of file
Deleted: tags/1_1_1_rc1/docs/userguide/en/master.xml
===================================================================
--- trunk/docs/userguide/en/master.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/master.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3CR3//EN"
-"../../../../../resources/support/docbook-dtd/docbookx.dtd"
-[ <!ENTITY introduction SYSTEM "modules/a4jUGintro.xml">
- <!ENTITY technicalRequirements SYSTEM "modules/a4jUGtechreqs.xml">
- <!ENTITY getttingStarted SYSTEM "modules/a4jUGstart.xml">
- <!ENTITY envSettings SYSTEM "modules/a4jUGenvsettings.xml">
- <!ENTITY usingAJAX SYSTEM "modules/a4jUGusingAJAX.xml">
- <!ENTITY componentDetails SYSTEM
"../../build/generated/en/a4j_table.xml">
- <!ENTITY skinnability SYSTEM "modules/a4jUGskinnability.xml">
- <!ENTITY IDEintegration SYSTEM "modules/a4jUGideintegration.xml">
- <!ENTITY EVCP SYSTEM "modules/a4jUGevcp.xml">
- <!ENTITY resourceLinks SYSTEM "modules/a4jUGlinks.xml">
- <!ENTITY wadParams SYSTEM "modules/AUGWADParams.xml">
- <!ENTITY FAQ SYSTEM "modules/a4jUGfaq.xml"> ]>
-
-<book>
- <bookinfo>
- <title>Ajax4jsf Developer Guide</title>
- <subtitle>A JSF component library and framework for incorporating AJAX into Web
applications</subtitle>
- <copyright>
- <year>2007</year>
- <holder>Red Hat</holder>
- </copyright>
-
- </bookinfo>
- <toc/>
- &introduction;
- &technicalRequirements;
- &envSettings;
- &getttingStarted;
- &usingAJAX;
- &componentDetails;
- &skinnability;
- &IDEintegration;
-
-</book>
Copied: tags/1_1_1_rc1/docs/userguide/en/master.xml (from rev 163,
trunk/docs/userguide/en/master.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/master.xml (rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/master.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3CR3//EN"
+"../../../../jbosstools/trunk/documentation/resources/support/docbook-dtd/docbookx.dtd"
+[ <!ENTITY introduction SYSTEM "modules/a4jUGintro.xml">
+ <!ENTITY technicalRequirements SYSTEM "modules/a4jUGtechreqs.xml">
+ <!ENTITY getttingStarted SYSTEM "modules/a4jUGstart.xml">
+ <!ENTITY envSettings SYSTEM "modules/a4jUGenvsettings.xml">
+ <!ENTITY usingAJAX SYSTEM "modules/a4jUGusingAJAX.xml">
+ <!ENTITY componentDetails SYSTEM
"../../build/generated/en/a4j_table.xml">
+ <!ENTITY skinnability SYSTEM "modules/a4jUGskinnability.xml">
+ <!ENTITY IDEintegration SYSTEM "modules/a4jUGideintegration.xml">
+ <!ENTITY EVCP SYSTEM "modules/a4jUGevcp.xml">
+ <!ENTITY resourceLinks SYSTEM "modules/a4jUGlinks.xml">
+ <!ENTITY wadParams SYSTEM "modules/AUGWADParams.xml">
+ <!ENTITY FAQ SYSTEM "modules/a4jUGfaq.xml"> ]>
+
+<book>
+ <bookinfo>
+ <title>Ajax4jsf Developer Guide</title>
+ <subtitle>A JSF component library and framework for incorporating AJAX into Web
applications</subtitle>
+ <copyright>
+ <year>2007</year>
+ <holder>Red Hat</holder>
+ </copyright>
+
+ </bookinfo>
+ <toc/>
+ &introduction;
+ &technicalRequirements;
+ &envSettings;
+ &getttingStarted;
+ &usingAJAX;
+ &componentDetails;
+ &skinnability;
+ &IDEintegration;
+
+</book>
Deleted: tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGfaq.xml
===================================================================
--- trunk/docs/userguide/en/modules/a4jUGfaq.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGfaq.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,284 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<section id="FAQ" xreflabel="FAQ">
- <?dbhtml filename="FAQ.html"?>
- <sectioninfo>
- <keywordset>
- <keyword>RENDER_RESPONSE</keyword>
-
- <keyword>onComplete</keyword>
-
- <keyword>keepAlive</keyword>
- <keyword>requestDelay</keyword>
- </keywordset>
- </sectioninfo>
- <title>FAQ</title>
- <section id="DecidingWhatToChangeOnTheServerSide">
- <?dbhtml filename="DecidingWhatToChangeOnTheServerSide.html"?>
- <title>Deciding what to change on the server side</title>
- <para>
- As it was mentioned before, the list of zones to be reRendered can be
specified
- as EL expression. But there is a question that must be specified more
exactly.
- </para>
- <para>
- The list of Ids is formed during beforePhase of RENDER_RESPONSE. Therefore,
in
- this case one can point reRender to the Set type Bean's property
and fill
- the Set during a tracking request.
- </para>
- <para>
- It's the way to form a list of updatable areas dynamically.
- </para>
- </section>
- <section
id="CheckSendingRequestConditions.CustomJavaScriptBeforeRequest.OnSubmitAttribute">
- <?dbhtml
filename="CheckSendingRequestConditions.CustomJavaScriptBeforeRequest.OnSubmitAttribute.html"?>
-
- <title>Check sending request conditions. Custom JavaScript before request.
OnSubmit attribute</title>
- <para>
- To check on the client some terms of request sending, The <emphasis
role="italic">
- <property>"onSubmit</property>
- </emphasis>" attribute is added to all components, which may cause
the request. </para>
- <para><emphasis role="bold">Example: </emphasis>
- </para>
- <programlisting role="XML"><![CDATA[<h:inputText
id="i" value="#{beanText.kennung}">
- <a4j:support event="onfocus" onsubmit="doSomething();"
reRender="panelToReRender"/>
-</h:inputText>]]></programlisting>
- <para>
- So in this case "<emphasis
role="italic"><property>doSomething()</property>"</emphasis>
function is executed before the AJAX request.
- </para>
- <para>
- Besides, if this function returns "false", AJAX request
isn't fired.
- </para>
- <note>
- <title>Note:</title>
- <para>Behavior of our <emphasis role="italic">
- <property>"onsubmit"</property>
- </emphasis>slightly differs from the standard one.
- Do not return <emphasis role="italic">
- <property>"true"</property>
- </emphasis>
-if you want to fire the request - because
- <emphasis role="bold">
-<property><xxx><a4j:support event="onclick"
onsubmit="return true;"></property>
-</emphasis> is transformed into <xxx onclick="return true;
A4J.Submit(.... );" >
- and the request isn't fired also in this case (but the standard
event processing fired). You must only return <emphasis role="italic">
- <property>"false"</property>
- </emphasis>
-if your conditions weren't completed or perform some actions (if needed) without
any returns in case you need to fire it.
- </para>
- </note>
- </section>
- <section id="onCompleteAttribute.DifferencesAfterRelease1.0">
- <?dbhtml
filename="onCompleteAttribute.DifferencesAfterRelease1.0.html"?>
- <title> onCompelete attribute. Differences after release 1.0 </title>
- <para>
- To avoid differences with other JavaScript attributes, a function placement
in a
- JavaScript call is changed, instead of simple inserting of attribute content
(..oncomplete :anotherFunction(this)..),
- it places (oncomplete: function(){anotherFunction(this);}..) in anonymous
function,
- to allow put "chain" of statements in attribute.
- </para>
- <para>
- Since, <emphasis role="italic">
- <property>"this"</property>
- </emphasis>
-keyword will point to a parameters map instead of a control element as it was before.
- You may use <emphasis role="italic">
- <property>document.findElementById()</property>
- </emphasis>to get references to this object after a request
- is processed as when a page is updated in AJAX you will have reference to a
control,
- removed from a DOM tree.
- </para>
- <para>
- Or, if you are sure that your element is not updated, you can add
<emphasis role="italic">
- <property>"onsubmit"</property>
- </emphasis>
-in <emphasis role="bold">
- <property><a4j:support></property>
- </emphasis>
- (or onclick in <emphasis
role="bold"><property><a4j:commandLink/Button></property></emphasis>)
to place reference to known variable
- (<emphasis
role="bold"><property><a4j:commandLink onclick="var
myControl=this;"
oncomplete="anotherFunction(myControl)"/></property></emphasis>).
- </para>
- <important>
- <title>New:</title>
- <para>
- The onComplete syntax now is:
- </para>
- <programlisting role="XML">
- <![CDATA[<someAjaxActionComponent
...oncomplete="myFunc(req,event,data)".../>]]>
- </programlisting>
- <para>
- where the <property>event</property> is a variable where the JS
event copy that fires the request is placed into. One may use it to get the element
instead of this.
- and <property>data</property> is a variable that contains
deserialized value from the <property>data</property> attribute.
- </para>
-</important>
- </section>
- <section id="InvokeOnComponentUsingWithJSF1.2">
- <?dbhtml filename="InvokeOnComponentUsingWithJSF1.2.html"?>
- <title>InvokeOnComponent using with JSF 1.2</title>
- <para>
- Ajax4jsf currently does not use <emphasis
role="italic">invokeOnComponent</emphasis> because of the 2 reasons:
- </para>
- <itemizedlist>
- <listitem>
- Compatibility with JSF 1.1 and MyFaces applications is kept, due to a
big
- amount of code used in corporate applications.
-</listitem>
- <listitem>
- <emphasis role="italic"> InvokeOnComponent</emphasis> works
with already known clientId, and works fine for
- communication between widget and backed component, or updates content
of
- already rendered component. But there are some troubles to use this
method for more
- complex use-cases implemented in Ajax4jsf, as there is a choice for
updatable
- components in application logic, where it's necessary to
navigate in a components
- tree by the native id, with
<property>findComponent()</property> methods.
- </listitem>
- </itemizedlist>
- <para>
- Thus, for example, only entire dataTable can be updated in
- response (but all AJAX action components inside table work properly).
- </para>
- </section>
- <section id="RegionsInDataTables">
- <?dbhtml filename="RegionsInDataTables.html"?>
- <title>Regions in Data Tables</title>
- <para>The regions in Data Tables aren't supported now, but the feature
will be implemented in a new Ajax4jsf version for JSF 1.2.</para>
- </section>
- <section id="keepAliveComponentGeneratesException">
- <?dbhtml filename="keepAliveComponentGeneratesException.html"?>
- <title>"keepAlive" component generates
exception</title>
- <para>To avoid this exception, don't forget that the component stores
beans in serialized view, but your bean should implement
java.io.Serializable.</para>
- </section>
- <section id="FilterUsageDamagesAnApplicationLayout">
- <?dbhtml filename="FilterUsageDamagesAnApplicationLayout.html"?>
- <title>Filter usage damages an application layout</title>
- <para>Ajax4jsf uses <property>filters</property> for correction of
xhtml code received on an AJAX response,
-because when a response is recieved from the server, Ajax4jsf makes direct changes in
-DOM tree and browser doesn't make any corrections in generated xhtml. There
-are two ways for setting <property>filters</property> that could be used in
an Ajax4jsf-based
-application.</para>
- <para>
-The first one:</para>
-<programlisting role="XML"><![CDATA[<context-param filter>
- <display-name>Ajax4jsf Filter</display-name>
- <filter-name>ajax4jsf</filter-name>
- <filter-class>org.ajax4jsf.Filter</filter-class>
-</filter>]]></programlisting>
- <para>This <property>filter</property> is based on Tidy Filter
usage and recommended for applications
-with complicated or non-standard markup, as all the necessary xhtml code
-corrections are made by the filter when a response comes from the server.</para>
- <para>
-Anyway, some obvious errors could damage a layout, if it happens, make sure that the
-markup corresponds to the xhtml-strict specification.
-
-</para>
- <para>The second one:</para>
-<programlisting role="XML"><![CDATA[<filter>
- <display-name>org.ajax4jsf.FastFilter</display-name>
- <filter-name>ajax4jsf</filter-name>
- <filter-class>org.ajax4jsf.FastFilter</filter-class>
-</filter>]]></programlisting>
- <para>This <property>filter</property> is based on the Nekko pacer.
In this case an output xhtml code isn't
-strictly verified and it also could cause lot's of errors and corrupt a layout
as
-a result. Though if you sure that your application markup is really strict for this
-filter, the filter considerably accelerates all AJAX requests processing.
-</para>
- <para><emphasis role="bold">Extra
information</emphasis>.
-</para>
- <para>forceParcer parameters setting for
<property>filters</property>:</para>
-<programlisting role="XML"><![CDATA[<filter>
-...
-<init-param>
-<param-name>forceparser</param-name>
-<param-value>false</param-value>
-</init-param>
-...
-</filter>]]></programlisting>
- <para>The "false" setting for initialization parameter
switches off application of filters
-for non-AJAX requests, if "true" is chosen, the filter checks all
-requests.
-
-<important>
- <title>Changes for Ajax4jsf 1.1.0</title>
- <property>forceparser parameter</property> default value is false from this
version.
-</important>
-
-</para>
- </section>
- <section id="AFormIsNotSubmittedOrASetterIsNotCalledAfterAJAXrequest">
- <?dbhtml
filename="AFormIsNotSubmittedOrASetterIsNotCalledAfterAJAXrequest.html"?>
- <title>A form isn't submitted or a setter isn't called after
AJAX request </title>
- <para>This situation could happen because of conversion/validation errors on
form
-submission. In order to verify this, it's necessary to place this updating via
an AJAX
-error message inside a form:</para>
-<programlisting role="XML"><![CDATA[<a4j:outputPanel
ajaxRendered="true">
- <h:messages/>
-</a4j:outpurPanel>]]></programlisting>
- </section>
- <section id="IgnoreDupResponsesAndRequestDelay">
- <?dbhtml filename="IgnoreDupResponsesAndRequestDelay.html"?>
-
- <title>IgnoreDupResponses and requestDelay </title>
- <para>The <emphasis role="italic">
- <property>"IgnoreDupResponses"</property>
- </emphasis> attribute appeared from 1.0.4 RC1 version and is used on the
-client for response ignoring after an AJAX request if a newer request has been
-already sent.
-
-<emphasis role="italic">
- <property>"RequestDelay"</property>
- </emphasis> attribute also defines the client behavior. It sets the time
delay, after
-which another request could be sent, all other requests are taken away
-from a queue except the last one.
-</para>
- </section>
-
- <section id="EventQueueUsage">
- <?dbhtml filename="EventQueueUsage.html"?>
- <title>EventQueue usage</title>
- <para>The <emphasis role="italic">
- <property>"EventQueue"</property>
- </emphasis> attribute defines the query name where the requests are saved
-before their sending to the server. The queue is created for redundant requests
-deleting during frequent events, which call several requests forming one after
-another. The queue cuts redundant requests and send only the last one. The
-queue is created in any case and named on default, the attribute usage only
-re-defines this name.
-</para>
- </section>
-
- <section id="reRenderingfailed">
- <?dbhtml filename="reRenderingfailed.html"?>
- <title>reRendering failed. Hide/Show the components using
rendered</title>
- <para>
- During "show/hide" functionality implementation the main error happens
because of the "reRender" attribute of some AJAX Action Component is set
on a component that depends on rendered properties, i.e. a component that is to be
hidden/rendered is tried to be updated. The problem is that if
rendered="false" in this moment, the component isn't in the DOM
tree and can't be updated because of the general limitations described in the
Ajax Processing chapter.
-</para>
-<para>The correct variant of functionality implantation:</para>
-
-<orderedlist>
-<listitem><para>With the rendered attribute wrap the component that is to be
hidden or rendered on AJAX in a wrapper component (e.g.
a4j:outputPanel)</para></listitem>
-
-<listitem><para>Set reRender of an AJAX Action component on this wrapper
component instead of the component itself.</para></listitem>
-</orderedlist>
-
-<para><emphasis role="bold">Example:</emphasis></para>
-
- <programlisting role="XML"><![CDATA[...
-<a4j:outputPanel id="panel">
- <h:panelGroup rendered="#{bean.rendered}">
- <!--Some nested content to be hidden/shown depending on bean.rendered -->
-</h:panelGroup>
-</a4j:outputPanel>
-...
-<a4j:commandButton action=".." value=".."
reRender="panel"/>
-...
-]]></programlisting>
-
-<para>In this case the wrapper component always presents in the DOM tree and its
inner content could be updated dynamically on AJAX.</para>
-</section>
-
-<section id="ResourceNotRegisteredException">
- <?dbhtml filename="ResourceNotRegisteredException.html"?>
- <title>ResourceNotRegistered Exception</title>
-
- <para>Ajax4jsf registers its resources (scripts, images) after an application
is accessed and then accesses it via a generated URL. During an application development
when a developer constantly updates it on the server, it could happen that Ajax4jsf
re-registers its resources after every server restart and a browser tries to access them
via cashed URL.</para>
-
-<para>The problem is solved with browser cash update (e.g. CTRL+F5).</para>
-</section>
-</section>
\ No newline at end of file
Copied: tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGfaq.xml (from rev 163,
trunk/docs/userguide/en/modules/a4jUGfaq.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGfaq.xml (rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGfaq.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,284 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<section id="FAQ" xreflabel="FAQ">
+ <?dbhtml filename="FAQ.html"?>
+ <sectioninfo>
+ <keywordset>
+ <keyword>RENDER_RESPONSE</keyword>
+
+ <keyword>onComplete</keyword>
+
+ <keyword>keepAlive</keyword>
+ <keyword>requestDelay</keyword>
+ </keywordset>
+ </sectioninfo>
+ <title>FAQ</title>
+ <section id="DecidingWhatToChangeOnTheServerSide">
+ <?dbhtml filename="DecidingWhatToChangeOnTheServerSide.html"?>
+ <title>Deciding what to change on the server side</title>
+ <para>
+ As it was mentioned before, the list of zones to be reRendered can be
specified
+ as EL expression. But there is a question that must be specified more
exactly.
+ </para>
+ <para>
+ The list of Ids is formed during beforePhase of RENDER_RESPONSE. Therefore,
in
+ this case one can point reRender to the Set type Bean's property
and fill
+ the Set during a tracking request.
+ </para>
+ <para>
+ It's the way to form a list of updatable areas dynamically.
+ </para>
+ </section>
+ <section
id="CheckSendingRequestConditions.CustomJavaScriptBeforeRequest.OnSubmitAttribute">
+ <?dbhtml
filename="CheckSendingRequestConditions.CustomJavaScriptBeforeRequest.OnSubmitAttribute.html"?>
+
+ <title>Check sending request conditions. Custom JavaScript before request.
OnSubmit attribute</title>
+ <para>
+ To check on the client some terms of request sending, The <emphasis
role="italic">
+ <property>"onSubmit</property>
+ </emphasis>" attribute is added to all components, which may cause
the request. </para>
+ <para><emphasis role="bold">Example: </emphasis>
+ </para>
+ <programlisting role="XML"><![CDATA[<h:inputText
id="i" value="#{beanText.kennung}">
+ <a4j:support event="onfocus" onsubmit="doSomething();"
reRender="panelToReRender"/>
+</h:inputText>]]></programlisting>
+ <para>
+ So in this case "<emphasis
role="italic"><property>doSomething()</property>"</emphasis>
function is executed before the AJAX request.
+ </para>
+ <para>
+ Besides, if this function returns "false", AJAX request
isn't fired.
+ </para>
+ <note>
+ <title>Note:</title>
+ <para>Behavior of our <emphasis role="italic">
+ <property>"onsubmit"</property>
+ </emphasis>slightly differs from the standard one.
+ Do not return <emphasis role="italic">
+ <property>"true"</property>
+ </emphasis>
+if you want to fire the request - because
+ <emphasis role="bold">
+<property><xxx><a4j:support event="onclick"
onsubmit="return true;"></property>
+</emphasis> is transformed into <xxx onclick="return true;
A4J.Submit(.... );" >
+ and the request isn't fired also in this case (but the standard
event processing fired). You must only return <emphasis role="italic">
+ <property>"false"</property>
+ </emphasis>
+if your conditions weren't completed or perform some actions (if needed) without
any returns in case you need to fire it.
+ </para>
+ </note>
+ </section>
+ <section id="onCompleteAttribute.DifferencesAfterRelease1.0">
+ <?dbhtml
filename="onCompleteAttribute.DifferencesAfterRelease1.0.html"?>
+ <title> onCompelete attribute. Differences after release 1.0 </title>
+ <para>
+ To avoid differences with other JavaScript attributes, a function placement
in a
+ JavaScript call is changed, instead of simple inserting of attribute content
(..oncomplete :anotherFunction(this)..),
+ it places (oncomplete: function(){anotherFunction(this);}..) in anonymous
function,
+ to allow put "chain" of statements in attribute.
+ </para>
+ <para>
+ Since, <emphasis role="italic">
+ <property>"this"</property>
+ </emphasis>
+keyword will point to a parameters map instead of a control element as it was before.
+ You may use <emphasis role="italic">
+ <property>document.findElementById()</property>
+ </emphasis>to get references to this object after a request
+ is processed as when a page is updated in AJAX you will have reference to a
control,
+ removed from a DOM tree.
+ </para>
+ <para>
+ Or, if you are sure that your element is not updated, you can add
<emphasis role="italic">
+ <property>"onsubmit"</property>
+ </emphasis>
+in <emphasis role="bold">
+ <property><a4j:support></property>
+ </emphasis>
+ (or onclick in <emphasis
role="bold"><property><a4j:commandLink/Button></property></emphasis>)
to place reference to known variable
+ (<emphasis
role="bold"><property><a4j:commandLink onclick="var
myControl=this;"
oncomplete="anotherFunction(myControl)"/></property></emphasis>).
+ </para>
+ <important>
+ <title>New:</title>
+ <para>
+ The onComplete syntax now is:
+ </para>
+ <programlisting role="XML">
+ <![CDATA[<someAjaxActionComponent
...oncomplete="myFunc(req,event,data)".../>]]>
+ </programlisting>
+ <para>
+ where the <property>event</property> is a variable where the JS
event copy that fires the request is placed into. One may use it to get the element
instead of this.
+ and <property>data</property> is a variable that contains
deserialized value from the <property>data</property> attribute.
+ </para>
+</important>
+ </section>
+ <section id="InvokeOnComponentUsingWithJSF1.2">
+ <?dbhtml filename="InvokeOnComponentUsingWithJSF1.2.html"?>
+ <title>InvokeOnComponent using with JSF 1.2</title>
+ <para>
+ Ajax4jsf currently does not use <emphasis
role="italic">invokeOnComponent</emphasis> because of the 2 reasons:
+ </para>
+ <itemizedlist>
+ <listitem>
+ Compatibility with JSF 1.1 and MyFaces applications is kept, due to a
big
+ amount of code used in corporate applications.
+</listitem>
+ <listitem>
+ <emphasis role="italic"> InvokeOnComponent</emphasis> works
with already known clientId, and works fine for
+ communication between widget and backed component, or updates content
of
+ already rendered component. But there are some troubles to use this
method for more
+ complex use-cases implemented in Ajax4jsf, as there is a choice for
updatable
+ components in application logic, where it's necessary to
navigate in a components
+ tree by the native id, with
<property>findComponent()</property> methods.
+ </listitem>
+ </itemizedlist>
+ <para>
+ Thus, for example, only entire dataTable can be updated in
+ response (but all AJAX action components inside table work properly).
+ </para>
+ </section>
+ <section id="RegionsInDataTables">
+ <?dbhtml filename="RegionsInDataTables.html"?>
+ <title>Regions in Data Tables</title>
+ <para>The regions in Data Tables aren't supported now, but the feature
will be implemented in a new Ajax4jsf version for JSF 1.2.</para>
+ </section>
+ <section id="keepAliveComponentGeneratesException">
+ <?dbhtml filename="keepAliveComponentGeneratesException.html"?>
+ <title>"keepAlive" component generates
exception</title>
+ <para>To avoid this exception, don't forget that the component stores
beans in serialized view, but your bean should implement
java.io.Serializable.</para>
+ </section>
+ <section id="FilterUsageDamagesAnApplicationLayout">
+ <?dbhtml filename="FilterUsageDamagesAnApplicationLayout.html"?>
+ <title>Filter usage damages an application layout</title>
+ <para>Ajax4jsf uses <property>filters</property> for correction of
xhtml code received on an AJAX response,
+because when a response is recieved from the server, Ajax4jsf makes direct changes in
+DOM tree and browser doesn't make any corrections in generated xhtml. There
+are two ways for setting <property>filters</property> that could be used in
an Ajax4jsf-based
+application.</para>
+ <para>
+The first one:</para>
+<programlisting role="XML"><![CDATA[<context-param filter>
+ <display-name>Ajax4jsf Filter</display-name>
+ <filter-name>ajax4jsf</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+</filter>]]></programlisting>
+ <para>This <property>filter</property> is based on Tidy Filter
usage and recommended for applications
+with complicated or non-standard markup, as all the necessary xhtml code
+corrections are made by the filter when a response comes from the server.</para>
+ <para>
+Anyway, some obvious errors could damage a layout, if it happens, make sure that the
+markup corresponds to the xhtml-strict specification.
+
+</para>
+ <para>The second one:</para>
+<programlisting role="XML"><![CDATA[<filter>
+ <display-name>org.ajax4jsf.FastFilter</display-name>
+ <filter-name>ajax4jsf</filter-name>
+ <filter-class>org.ajax4jsf.FastFilter</filter-class>
+</filter>]]></programlisting>
+ <para>This <property>filter</property> is based on the Nekko pacer.
In this case an output xhtml code isn't
+strictly verified and it also could cause lot's of errors and corrupt a layout
as
+a result. Though if you sure that your application markup is really strict for this
+filter, the filter considerably accelerates all AJAX requests processing.
+</para>
+ <para><emphasis role="bold">Extra
information</emphasis>.
+</para>
+ <para>forceParcer parameters setting for
<property>filters</property>:</para>
+<programlisting role="XML"><![CDATA[<filter>
+...
+<init-param>
+<param-name>forceparser</param-name>
+<param-value>false</param-value>
+</init-param>
+...
+</filter>]]></programlisting>
+ <para>The "false" setting for initialization parameter
switches off application of filters
+for non-AJAX requests, if "true" is chosen, the filter checks all
+requests.
+
+<important>
+ <title>Changes for Ajax4jsf 1.1.0</title>
+ <property>forceparser parameter</property> default value is false from this
version.
+</important>
+
+</para>
+ </section>
+ <section id="AFormIsNotSubmittedOrASetterIsNotCalledAfterAJAXrequest">
+ <?dbhtml
filename="AFormIsNotSubmittedOrASetterIsNotCalledAfterAJAXrequest.html"?>
+ <title>A form isn't submitted or a setter isn't called after
AJAX request </title>
+ <para>This situation could happen because of conversion/validation errors on
form
+submission. In order to verify this, it's necessary to place this updating via
an AJAX
+error message inside a form:</para>
+<programlisting role="XML"><![CDATA[<a4j:outputPanel
ajaxRendered="true">
+ <h:messages/>
+</a4j:outpurPanel>]]></programlisting>
+ </section>
+ <section id="IgnoreDupResponsesAndRequestDelay">
+ <?dbhtml filename="IgnoreDupResponsesAndRequestDelay.html"?>
+
+ <title>IgnoreDupResponses and requestDelay </title>
+ <para>The <emphasis role="italic">
+ <property>"IgnoreDupResponses"</property>
+ </emphasis> attribute appeared from 1.0.4 RC1 version and is used on the
+client for response ignoring after an AJAX request if a newer request has been
+already sent.
+
+<emphasis role="italic">
+ <property>"RequestDelay"</property>
+ </emphasis> attribute also defines the client behavior. It sets the time
delay, after
+which another request could be sent, all other requests are taken away
+from a queue except the last one.
+</para>
+ </section>
+
+ <section id="EventQueueUsage">
+ <?dbhtml filename="EventQueueUsage.html"?>
+ <title>EventQueue usage</title>
+ <para>The <emphasis role="italic">
+ <property>"EventQueue"</property>
+ </emphasis> attribute defines the query name where the requests are saved
+before their sending to the server. The queue is created for redundant requests
+deleting during frequent events, which call several requests forming one after
+another. The queue cuts redundant requests and send only the last one. The
+queue is created in any case and named on default, the attribute usage only
+re-defines this name.
+</para>
+ </section>
+
+ <section id="reRenderingfailed">
+ <?dbhtml filename="reRenderingfailed.html"?>
+ <title>reRendering failed. Hide/Show the components using
rendered</title>
+ <para>
+ During "show/hide" functionality implementation the main error happens
because of the "reRender" attribute of some AJAX Action Component is set
on a component that depends on rendered properties, i.e. a component that is to be
hidden/rendered is tried to be updated. The problem is that if
rendered="false" in this moment, the component isn't in the DOM
tree and can't be updated because of the general limitations described in the
Ajax Processing chapter.
+</para>
+<para>The correct variant of functionality implantation:</para>
+
+<orderedlist>
+<listitem><para>With the rendered attribute wrap the component that is to be
hidden or rendered on AJAX in a wrapper component (e.g.
a4j:outputPanel)</para></listitem>
+
+<listitem><para>Set reRender of an AJAX Action component on this wrapper
component instead of the component itself.</para></listitem>
+</orderedlist>
+
+<para><emphasis role="bold">Example:</emphasis></para>
+
+ <programlisting role="XML"><![CDATA[...
+<a4j:outputPanel id="panel">
+ <h:panelGroup rendered="#{bean.rendered}">
+ <!--Some nested content to be hidden/shown depending on bean.rendered -->
+ </h:panelGroup>
+</a4j:outputPanel>
+...
+<a4j:commandButton action=".." value=".."
reRender="panel"/>
+...
+]]></programlisting>
+
+<para>In this case the wrapper component always presents in the DOM tree and its
inner content could be updated dynamically on AJAX.</para>
+</section>
+
+<section id="ResourceNotRegisteredException">
+ <?dbhtml filename="ResourceNotRegisteredException.html"?>
+ <title>ResourceNotRegistered Exception</title>
+
+ <para>Ajax4jsf registers its resources (scripts, images) after an application
is accessed and then accesses it via a generated URL. During an application development
when a developer constantly updates it on the server, it could happen that Ajax4jsf
re-registers its resources after every server restart and a browser tries to access them
via cashed URL.</para>
+
+<para>The problem is solved with browser cash update (e.g. CTRL+F5).</para>
+</section>
+</section>
\ No newline at end of file
Deleted: tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGstart.xml
===================================================================
--- trunk/docs/userguide/en/modules/a4jUGstart.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGstart.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -1,252 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter id="GettingStartedWithAjax4jsf"
xreflabel="GettingStartedWithAjax4jsf">
- <?dbhtml filename="GettingStartedWithAjax4jsf.html"?>
-
- <chapterinfo>
- <keywordset>
- <keyword>Ajax4jsf Filter</keyword>
-
- <keyword>JSF</keyword>
-
- <keyword>Ajax4jsf</keyword>
- </keywordset>
- </chapterinfo>
-
- <title>Getting Started with Ajax4jsf</title>
- <section id="Environment">
- <?dbhtml filename="Environment.html" ?>
- <title>Environment</title>
- <para>
- To use Ajax4jsf framework you need JDK 1.4 or higher, any JSF implementation
- and your favorite Servlet Container. To read more on the
<property>Environments</property>, see further chapters.</para>
- <para>
- Ajax4jsf is designed in an easy-to-use way, so that you should do only a few simple
steps to get AJAX functionality in your JSF application.
- </para>
- </section>
- <section id="DownloadingAjax4jsf">
- <?dbhtml filename="DownloadingAjax4jsf.html" ?>
- <title>Downloading Ajax4jsf</title>
- <para>The latest release of <property>Ajax4jsf</property> is
available for download at:<simplelist><member><ulink
url="http://labs.jboss.com/portal/jbossajax4jsf/downloads">h...
- in the <property>Ajax4jsf</property> project area under
JBoss.</para>
- </section>
- <section id="Installation">
- <?dbhtml filename="Installation.html" ?>
- <title>Installation</title>
- <itemizedlist>
- <listitem>
-
- Unzip <emphasis role="italic">
- <property>"ajax4jsf.zip"</property>
- </emphasis> file to the chosen folder.
-
- </listitem>
- <listitem>
-
- Copy <emphasis
role="italic"><property>"ajax4jsf.jar"</property></emphasis>
and <emphasis
role="italic"><property>"oscache-2.3.2jar"</property></emphasis>
files into the <emphasis role="italic">
- <property>"WEB-INF/lib"</property>
- </emphasis> folder of your application.
-
- </listitem>
- <listitem>
-
- Add the following content into the <emphasis role="italic">
- <property>"WEB-INF/web.xml"</property>
- </emphasis> file of your application:
-
- <programlisting role="XML"><![CDATA[<filter>
- <display-name>Ajax4jsf Filter</display-name>
- <filter-name>ajax4jsf</filter-name>
- <filter-class>org.ajax4jsf.Filter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>ajax4jsf</filter-name>
- <servlet-name>Faces Servlet</servlet-name>
- <dispatcher>REQUEST</dispatcher>
- <dispatcher>FORWARD</dispatcher>
- <dispatcher>INCLUDE</dispatcher>
- </filter-mapping>]]></programlisting>
- <note>
- <title>Note:</title>
- <para>You can copy and paste the above text from the <emphasis
role="italic">
- <property>"README.txt"</property>
- </emphasis> file.</para>
- </note>
- </listitem>
- <listitem>
-
- <para>Add the following line to each JSP page of your application where you
are going to bring in AJAX functionality.</para>
- <programlisting role="XML"> <![CDATA[<%@ taglib
uri="https://ajax4jsf.dev.java.net/ajax"
prefix="a4j"%>]]></programlisting>
- <para>For XHTML pages:</para>
- <programlisting
role="XML"><xmlns:a4j="https://ajax4jsf.dev.java...
- </listitem>
- </itemizedlist>
- </section>
- <section id="SimpleAJAXEchoProject">
- <?dbhtml filename="SimpleAJAXEchoProject.html" ?>
- <title>Simple AJAX Echo Project </title>
- <para>
- In our JSF project you need only one JSP page that has a form with a couple of
child tags:
- <emphasis role="bold">
- <property><h:inputText></property>
- </emphasis> and <emphasis role="bold">
- <property><h:outputText></property>
- </emphasis>.
- </para>
- <para>This simple application let you input some text into the <emphasis
role="bold">
- <property><h:inputText></property>
- </emphasis>,
- send data to the server, and see the server response as a value of <emphasis
role="bold">
- <property><h:outputText></property>
- </emphasis>.
- </para>
- <section id="JSPPage">
- <?dbhtml filename="JSPPage.html"?>
- <title>JSP Page</title>
- <para>Here is the necessary page (echo.jsp):</para>
- <programlisting role="JSP"> <![CDATA[<%@ taglib
uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
- <%@ taglib
uri="https://ajax4jsf.dev.java.net/ajax"
prefix="a4j"%>
- <%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
- <%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
- <html>
- <head>
- <title>repeater </title>
- </head>
- <body>
- <f:view>
- <h:form>
- <h:inputText size="50" value="#{bean.text}" >
- <a4j:support event="onkeyup" reRender="rep"/>
- </h:inputText>
- <h:outputText value="#{bean.text}" id="rep"/>
- </h:form>
- </f:view>
- </body>
- </html>]]></programlisting>
- <para>The only line that distinguishes this page from a
"regular" JSF one is</para>
- <programlisting role="XML"><![CDATA[<a4j:support
event="onkeyup" reRender="rep"/>]]></programlisting>
- <para>The line adds an AJAX support to the parent <emphasis
role="bold">
- <property><h:inputText></property>
- </emphasis> tag. This support is
- bound to "onkeyup" JavaScript event, so that each time when
this event is fired on the
- parent tag, our application sends an AJAX request to the server. It means that
the
- "text" field pointed to our managed bean property contains the
"freshest" value of our input.
- </para>
- <para>
- The value of <emphasis
role="italic"><property>"reRender"</property></emphasis>
attribute of the <emphasis role="bold">
- <property><a4j:support></property>
- </emphasis> tag defines which part(s) of our
- page is (are) to be updated. In this case, the only part of the page to
- update is the <emphasis role="bold">
- <property><h:outputText></property>
- </emphasis> tag because its ID value matches to the value of <emphasis
role="italic"><property>"reRender"</property></emphasis>
- attribute. As you see, it's not difficult to update multiple elements
on the page, only list their IDs
- as the value of <emphasis
role="italic"><property>"reRender"</property></emphasis>.
- </para>
- </section>
- <section id="DataBean">
- <?dbhtml filename="DataBean.html"?>
- <title>Data Bean</title>
- <para>In order to build this application, you should create a managed
bean:</para>
- <programlisting role="JAVA">package demo;
-public class Bean {
-private String text;
-public Bean() {
-}
- public String getText() {
-return text;
-}
-public void setText(String text) {
-this.text = text;
-}
-}</programlisting>
- </section>
- <section id="faces-config.xml">
- <?dbhtml filename="faces-config.xml.html"?>
- <title>faces-config.xml</title>
- <para>Next, it's necessary to register your bean inside of the
faces-config.xml file:</para>
- <programlisting role="XML"> <![CDATA[<?xml
version="1.0" encoding="UTF-8"?>
- <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer
Faces Config 1.1//EN"
- "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
- <faces-config>
- <managed-bean>
- <managed-bean-name>bean</managed-bean-name>
- <managed-bean-class>demo.Bean</managed-bean-class>
- <managed-bean-scope>request</managed-bean-scope>
- <managed-property>
- <property-name>text</property-name>
- <value/>
- </managed-property>
- </managed-bean>
- </faces-config>]]></programlisting>
- <para> <note>
- <title>Note:</title>
- <para>Nothing that relates directly to Ajax4jsf is required
- in the configuration file.</para>
- </note></para>
- </section>
- <section id="Web.xml">
- <?dbhtml filename="Web.xml.html"?>
- <title>Web.xml</title>
- <para>It is also necessary to add jar files (see <ulink
url="GettingStartedWithAjax4jsf.html#Installation">installation
chapter</ulink>) and modify the "web.xml" file:
- </para>
- <programlisting role="XML"> <![CDATA[<?xml
version="1.0"?>
- <web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
-
- <display-name>a4jEchoText</display-name>
- <context-param>
- <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
- <param-value>server</param-value>
- </context-param>
- <filter>
- <display-name>Ajax4jsf Filter</display-name>
- <filter-name>ajax4jsf</filter-name>
- <filter-class>org.ajax4jsf.Filter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>ajax4jsf</filter-name>
- <servlet-name>Faces Servlet</servlet-name>
- <dispatcher>REQUEST</dispatcher>
- <dispatcher>FORWARD</dispatcher>
- <dispatcher>INCLUDE</dispatcher>
- </filter-map>
- <listener>
- <listener-class>
- com.sun.faces.config.ConfigureListener
- </listener-class>
- </listener>
-
- <!-- Faces Servlet -->
- <servlet>
- <servlet-name>Faces Servlet</servlet-name>
- <servlet-class>
- javax.faces.webapp.FacesServlet
- </servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <!-- Faces Servlet Mapping -->
- <servlet-mapping>
- <servlet-name>Faces Servlet</servlet-name>
- <url-pattern>*.jsf</url-pattern>
- </servlet-mapping>
- <login-config>
- <auth-method>BASIC</auth-method>
- </login-config>
- </web-app>]]></programlisting>
- <para>Now your application should work.</para>
- </section>
- <section id="Deployment">
- <?dbhtml filename="Deployment.html"?>
- <title>Deployment</title>
- <para>Finally, you should be able to locate this application onto your Web
- server. Any server could be chosen. To start your project, point
- your browser at
-<simplelist><member><ulink
url="http://localhost:8080/a4jEchoText/echo.jsf">http://localhost:8080/a4jEchoText/echo.jsf</ulink></member></simplelist>
-</para>
-
-
- </section>
- </section>
-</chapter>
Copied: tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGstart.xml (from rev 163,
trunk/docs/userguide/en/modules/a4jUGstart.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGstart.xml (rev
0)
+++ tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGstart.xml 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,252 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter id="GettingStartedWithAjax4jsf"
xreflabel="GettingStartedWithAjax4jsf">
+ <?dbhtml filename="GettingStartedWithAjax4jsf.html"?>
+
+ <chapterinfo>
+ <keywordset>
+ <keyword>Ajax4jsf Filter</keyword>
+
+ <keyword>JSF</keyword>
+
+ <keyword>Ajax4jsf</keyword>
+ </keywordset>
+ </chapterinfo>
+
+ <title>Getting Started with Ajax4jsf</title>
+ <section id="Environment">
+ <?dbhtml filename="Environment.html" ?>
+ <title>Environment</title>
+ <para>
+ To use Ajax4jsf framework you need JDK 1.4 or higher, any JSF implementation
+ and your favorite Servlet Container. To read more on the
<property>Environments</property>, see further chapters.</para>
+ <para>
+ Ajax4jsf is designed in an easy-to-use way, so that you should do only a few simple
steps to get AJAX functionality in your JSF application.
+ </para>
+ </section>
+ <section id="DownloadingAjax4jsf">
+ <?dbhtml filename="DownloadingAjax4jsf.html" ?>
+ <title>Downloading Ajax4jsf</title>
+ <para>The latest release of <property>Ajax4jsf</property> is
available for download at:<simplelist><member><ulink
url="http://labs.jboss.com/portal/jbossajax4jsf/downloads">h...
+ in the <property>Ajax4jsf</property> project area under
JBoss.</para>
+ </section>
+ <section id="Installation">
+ <?dbhtml filename="Installation.html" ?>
+ <title>Installation</title>
+ <itemizedlist>
+ <listitem>
+
+ Unzip <emphasis role="italic">
+ <property>"ajax4jsf.zip"</property>
+ </emphasis> file to the chosen folder.
+
+ </listitem>
+ <listitem>
+
+ Copy <emphasis
role="italic"><property>"ajax4jsf.jar"</property></emphasis>
and <emphasis
role="italic"><property>"oscache-2.3.2jar"</property></emphasis>
files into the <emphasis role="italic">
+ <property>"WEB-INF/lib"</property>
+ </emphasis> folder of your application.
+
+ </listitem>
+ <listitem>
+
+ Add the following content into the <emphasis role="italic">
+ <property>"WEB-INF/web.xml"</property>
+ </emphasis> file of your application:
+
+ <programlisting role="XML"><![CDATA[<filter>
+ <display-name>Ajax4jsf Filter</display-name>
+ <filter-name>ajax4jsf</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>ajax4jsf</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>]]></programlisting>
+ <note>
+ <title>Note:</title>
+ <para>You can copy and paste the above text from the <emphasis
role="italic">
+ <property>"README.txt"</property>
+ </emphasis> file.</para>
+ </note>
+ </listitem>
+ <listitem>
+
+ <para>Add the following line to each JSP page of your application where you
are going to bring in AJAX functionality.</para>
+ <programlisting role="XML"> <![CDATA[<%@ taglib
uri="https://ajax4jsf.dev.java.net/ajax"
prefix="a4j"%>]]></programlisting>
+ <para>For XHTML pages:</para>
+ <programlisting
role="XML"><xmlns:a4j="https://ajax4jsf.dev.java...
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section id="SimpleAJAXEchoProject">
+ <?dbhtml filename="SimpleAJAXEchoProject.html" ?>
+ <title>Simple AJAX Echo Project </title>
+ <para>
+ In our JSF project you need only one JSP page that has a form with a couple of
child tags:
+ <emphasis role="bold">
+ <property><h:inputText></property>
+ </emphasis> and <emphasis role="bold">
+ <property><h:outputText></property>
+ </emphasis>.
+ </para>
+ <para>This simple application let you input some text into the <emphasis
role="bold">
+ <property><h:inputText></property>
+ </emphasis>,
+ send data to the server, and see the server response as a value of <emphasis
role="bold">
+ <property><h:outputText></property>
+ </emphasis>.
+ </para>
+ <section id="JSPPage">
+ <?dbhtml filename="JSPPage.html"?>
+ <title>JSP Page</title>
+ <para>Here is the necessary page (echo.jsp):</para>
+ <programlisting role="JSP"> <![CDATA[<%@ taglib
uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
+ <%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+ <%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+ <html>
+ <head>
+ <title>repeater </title>
+ </head>
+ <body>
+ <f:view>
+ <h:form>
+ <h:inputText size="50" value="#{bean.text}" >
+ <a4j:support event="onkeyup" reRender="rep"/>
+ </h:inputText>
+ <h:outputText value="#{bean.text}" id="rep"/>
+ </h:form>
+ </f:view>
+ </body>
+ </html>]]></programlisting>
+ <para>The only line that distinguishes this page from a
"regular" JSF one is</para>
+ <programlisting role="XML"><![CDATA[<a4j:support
event="onkeyup" reRender="rep"/>]]></programlisting>
+ <para>The line adds an AJAX support to the parent <emphasis
role="bold">
+ <property><h:inputText></property>
+ </emphasis> tag. This support is
+ bound to "onkeyup" JavaScript event, so that each time when
this event is fired on the
+ parent tag, our application sends an AJAX request to the server. It means that
the
+ "text" field pointed to our managed bean property contains the
"freshest" value of our input.
+ </para>
+ <para>
+ The value of <emphasis
role="italic"><property>"reRender"</property></emphasis>
attribute of the <emphasis role="bold">
+ <property><a4j:support></property>
+ </emphasis> tag defines which part(s) of our
+ page is (are) to be updated. In this case, the only part of the page to
+ update is the <emphasis role="bold">
+ <property><h:outputText></property>
+ </emphasis> tag because its ID value matches to the value of <emphasis
role="italic"><property>"reRender"</property></emphasis>
+ attribute. As you see, it's not difficult to update multiple elements
on the page, only list their IDs
+ as the value of <emphasis
role="italic"><property>"reRender"</property></emphasis>.
+ </para>
+ </section>
+ <section id="DataBean">
+ <?dbhtml filename="DataBean.html"?>
+ <title>Data Bean</title>
+ <para>In order to build this application, you should create a managed
bean:</para>
+ <programlisting role="JAVA">package demo;
+
+public class Bean {
+ private String text;
+ public Bean() {
+ }
+ public String getText() {
+ return text;
+ }
+ public void setText(String text) {
+ this.text = text;
+ }
+}</programlisting>
+ </section>
+ <section id="faces-config.xml">
+ <?dbhtml filename="faces-config.xml.html"?>
+ <title>faces-config.xml</title>
+ <para>Next, it's necessary to register your bean inside of the
faces-config.xml file:</para>
+ <programlisting role="XML"> <![CDATA[<?xml
version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer
Faces Config 1.1//EN"
+ "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+ <faces-config>
+ <managed-bean>
+ <managed-bean-name>bean</managed-bean-name>
+ <managed-bean-class>demo.Bean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ <managed-property>
+ <property-name>text</property-name>
+ <value/>
+ </managed-property>
+ </managed-bean>
+ </faces-config>]]></programlisting>
+ <para> <note>
+ <title>Note:</title>
+ <para>Nothing that relates directly to Ajax4jsf is required
+ in the configuration file.</para>
+ </note></para>
+ </section>
+ <section id="Web.xml">
+ <?dbhtml filename="Web.xml.html"?>
+ <title>Web.xml</title>
+ <para>It is also necessary to add jar files (see <ulink
url="GettingStartedWithAjax4jsf.html#Installation">installation
chapter</ulink>) and modify the "web.xml" file:
+ </para>
+ <programlisting role="XML"> <![CDATA[<?xml
version="1.0"?>
+ <web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+ <display-name>a4jEchoText</display-name>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <filter>
+ <display-name>Ajax4jsf Filter</display-name>
+ <filter-name>ajax4jsf</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>ajax4jsf</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-map>
+ <listener>
+ <listener-class>
+ com.sun.faces.config.ConfigureListener
+ </listener-class>
+ </listener>
+
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>
+ javax.faces.webapp.FacesServlet
+ </servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+ </web-app>]]></programlisting>
+ <para>Now your application should work.</para>
+ </section>
+ <section id="Deployment">
+ <?dbhtml filename="Deployment.html"?>
+ <title>Deployment</title>
+ <para>Finally, you should be able to locate this application onto your Web
+ server. Any server could be chosen. To start your project, point
+ your browser at
+<simplelist><member><ulink
url="http://localhost:8080/a4jEchoText/echo.jsf">http://localhost:8080/a4jEchoText/echo.jsf</ulink></member></simplelist>
+</para>
+
+
+ </section>
+ </section>
+</chapter>
Deleted: tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGusingAJAX.xml
===================================================================
--- trunk/docs/userguide/en/modules/a4jUGusingAJAX.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGusingAJAX.xml 2007-05-04 01:10:03 UTC
(rev 168)
@@ -1,316 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<chapter id="BasicConceptsOfTheAjax4jsfFramework"
xreflabel="BasicConceptsOfTheAjax4jsfFramework">
- <?dbhtml filename="BasicConceptsOfTheAjax4jsfFramework.html"?>
-
- <chapterinfo>
- <keywordset>
- <keyword>AjaxContainer</keyword>
-
- <keyword>Request Processing</keyword>
-
- <keyword>Ajax4jsf</keyword>
- </keywordset>
- </chapterinfo>
-
- <title>Basic concepts of the Ajax4jsf Framework</title>
- <section id="introToBasics">
- <?dbhtml filename="introToBasics.html"?>
- <title>Introduction</title>
- <para>The framework is implemented as a component library which adds AJAX
capability into existing
- pages, so you don't need to write any JavaScript code or to replace
existing
- components with new AJAX widgets. <property>Ajax4jsf</property> enables
page-wide AJAX support instead of the
- traditional component-wide support. So, you can define the event on the page that
- invokes an AJAX request and the areas of the page that should be synchronized with
the JSF
- Component Tree after the AJAX request changes the data on the server according to
the
- events fired on the client.</para>
- <para>Next Figure shows how it works:</para>
- <figure>
- <title>Request Processing flow</title>
- </figure>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/newpic1.jpg"/>
- </imageobject>
- </mediaobject>
- <para><property>Ajax4jsf</property> allows to define (by means of
JSF tags) different parts of a JSF page you
- wish to update with an AJAX request and provide a few options to send AJAX
requests to
- the server. Also JSF page doesn't change from a
"regular" JSF
- page and you don't need to write any JavaScript or XMLHttpRequest
objects by hands, everything is done automatically.</para>
- </section>
- <section id="ArchitectureOverview">
- <?dbhtml filename="ArchitectureOverview.html"?>
- <title>Architecture Overview</title>
- <para>Next figure lists several important elements of the
<property>Ajax4jsf</property> framework</para>
- <figure>
- <title>Ajax4jsf component structure</title>
- </figure>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/newpic2.jpg"/>
- </imageobject>
- </mediaobject>
- <formalpara>
- <title>Ajax Filter.</title>
- <para>To get all benefits of <property>Ajax4jsf</property>, you
should register an AJAX Filter in web.xml
- file of your application.The AJAX Filter recognizes multiple request types. The
sequence diagram on Figure 3
- shows the difference in processing of a "regular" JSF request and
an AJAX request.</para>
- </formalpara>
- <para>In the first case the whole JSF tree will be encoded,
- in the second one option it depends on the "size" of the AJAX
region (you can define AJAX region
- by using the <emphasis
role="bold"><property><a4j:region></property></emphasis>).
As you can see, in the second case the filter parses
- the content of an AJAX response before sending it to the client side.</para>
- <para>Have a look at the next picture to understand these two
ways:</para>
- <figure>
- <title>Request Processing sequence diagram</title>
- </figure>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/newpic3.jpg"/>
- </imageobject>
- </mediaobject>
- <para>In both cases, the information about required static or dynamic resources
that your application
- requests is registered in the ResourseBuilder class.</para>
- <para>When a request for a resource comes (Figure 4), the AJAX filter checks
the Resource Cache
- for this resource and if it is there, the resource will be sent to the client.
Otherwise,
- the filter will search for the resource among those that are registered by the
- ResourceBuilder. If the resource is registered, the AJAX filter will send a request
to the
- ResourceBuilder to create (deliver) the resource.</para>
- <para>Next Figure shows the ways of resource request processing.</para>
- <figure>
- <title>Resource request sequence diagram</title>
- </figure>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/newpic4.jpg"/>
- </imageobject>
- </mediaobject>
- <formalpara>
- <title>AJAX Action Components</title>
- <para>
- There are four AJAX Action Components: AjaxCommandButton, AjaxCommandLink,
AjaxPoll and AjaxSupport.
- You can use them to send AJAX requests from the client side.
- </para>
- </formalpara>
- <formalpara>
- <title>AJAX Containers</title>
- <para>
- AjaxContainer is an interface that describes an area on your JSF page that should
be decoded
- during an AJAX request. AjaxViewRoot and AjaxRegion are implementations of this
interface.
- </para>
- </formalpara>
- <formalpara>
- <title>JavaScript Engine</title>
- <para><property> Ajax4jsf</property> JavaScript Engine runs on
the client-side. It knows how to update different areas
- on your JSF page based on the information from the Ajax response. Do
- not use this JavaScript code directly, as it is available automatically.
- </para>
- </formalpara>
- </section>
- <section id="LimitationsAndRules">
- <?dbhtml filename="LimitationAndRules.html"?>
- <title>Limitations and Rules</title>
- <para>In order to create AJAX JSF applications properly, keep the following
points in mind:</para>
- <itemizedlist>
- <listitem>
- The AJAX framework should not append or delete, but only replace elements on the
page. For successful updates, an element with the same ID as in the response must exist on
the page. If you'd like to append any code to a page, put in a placeholder for it
(any empty element). For the same reason, it's recommended to place messages in
the<emphasis role="italic">
- <property>"AjaxOutput"</property>
- </emphasis> component (as no messages is also a message).
- </listitem>
- <listitem>
- Don't use <emphasis role="bold">
- <property><f:verbatim></property>
- </emphasis> for self-rendered containers, since this component is
transient and not saved in the tree.
- </listitem>
- <listitem>
- AJAX requests are made by XMLHttpRequest functions in XML format, but this XML
bypasses most validations and the corrections that might be made in a browser. So, create
only strict standards-compliant code for HTML and XHTML, without skipping any required
elements or attributes. Any necessary XML corrections are automatically made by the XML
filter on the server, but lot's of unexpected effects can be produced by an
incorrect HTML code.
- </listitem>
- </itemizedlist>
- </section>
- <section id="HowTo...">
- <?dbhtml filename="HowTo.html"?>
- <title>How To...</title>
- <section id="SendAnAJAXRequest">
- <?dbhtml filename="SendAnAJAXRequest.html"?>
- <title>Send an AJAX request</title>
- <para>There are different ways to send AJAX requests from your JSF page. You
may use
- <emphasis
role="bold"><property><a4j:commandButton></property></emphasis>,
<emphasis role="bold">
- <property><a4j:commandLink></property>, <emphasis
role="bold"><property><a4j:poll></property></emphasis>
- </emphasis> or <emphasis role="bold">
- <property><a4j:support></property>
- </emphasis> tags.
- </para>
- <para>All these tags hide the usual JavaScript activities that are required
for an XMHttpRequest
- object building and an AJAX request sending. Also, they allow you to decide
which components of
- your JSF page are to be re-rendered as a result of the AJAX response (you can
list the
- IDs of these components in the "reRender" attribute).
- </para>
- <para>
- <emphasis role="bold">
- <property><a4j:commandButton></property>
- </emphasis> and <emphasis role="bold">
- <property><a4j:commandLink></property>
- </emphasis> tags are used to send an AJAX
- request on "onclick" JavaScript event.
- </para>
- <para>
- <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> tag are used to send an AJAX
- request periodically using timer.
- </para>
- <para>The <emphasis role="bold">
- <property><a4j:support></property>
- </emphasis> tag allows you to add AJAX functionality to standard JSF
components
- and send AJAX request onto a chosen JavaScript event:
"onkeyup", "onmouseover",
- etc.
- </para>
- <para>Most important attributes of components that provide AJAX request
calling features are:</para>
- <itemizedlist>
- <listitem>
- <emphasis role="italic">
- <property>"reRender attribute"</property>
- </emphasis> as it was mentioned before specifies components to be
reRendered
- after AJAX response. The attribute can be specified using EL expression and
formed dynamicaly on the
- server side (see <ulink url="index.html#FAQ">FAQ
chapter</ulink>).
- </listitem>
- <listitem>
- <emphasis role="italic">
- <property>"RequestDelay"</property>
- </emphasis> attribute is used for a requests frequency regulation.
- </listitem>
- </itemizedlist>
- <programlisting role="XML"><![CDATA[<h:inputText
size="50" value="#{bean.text}">
- <a4j:support event="onkeyup" RequestDelay="3"/>
-</h:inputText>]]></programlisting>
- <para>So every next request from the frequent keyboard events will be
delayed
- on 3 ms to reduce the number of requests.
- </para>
- <itemizedlist>
- <listitem>
- <emphasis role="italic">
- <property>"EventsQueue"</property>
- </emphasis> is a queue that stores the next request.
- </listitem>
- <listitem>
- <emphasis role="italic">
- <property>"LimitToList"</property>
- </emphasis> attribute is used to regulate updatable regions. Setting
- it to true limits the updatable areas only to specified in
- reRender list, in other case all Output Panels of the region are updated.
- </listitem>
- <listitem> <emphasis role="italic">
- <property>"ajaxSingle"</property>
- </emphasis> attributes specify regions to be sent with a request,
- if "false" it is a full region, in other case
it's is only a control caused
- event.
-</listitem>
- </itemizedlist>
- </section>
- <section id="DecideWhatToSend">
- <?dbhtml filename="DecideWhatToSend.html"?>
- <title>Decide What to Send</title>
- <para>You may describe a region on the page you wish to send to the server,
in this way you can
- control what part of the JSF View is decoded on the server side when you send
an
- AJAX request.
- </para>
- <para>The easiest way to describe an AJAX region on your JSF page is to do
nothing,
- because the content between the <emphasis role="bold">
- <property><f:view></property>
- </emphasis> and <emphasis role="bold">
- <property></f:view></property>
- </emphasis> tags is considered
- the default AJAX region.
- </para>
- <para>You may define multiple AJAX regions on the JSF page (they can even be
nested) by using
- the <emphasis role="bold">
- <property><a4j:region></property>
- </emphasis> tag.
- </para>
- <para>If you wish to render the content of AJAX response outside of the
active region then
- the value of the "renderRegionOnly" attribute should be set
to "false". Otherwise, your
- AJAX updates are limited to elements of the active region.
- </para>
- </section>
- <section id="DecideWhatToChange">
- <?dbhtml filename="DecideWhatToChange.html"?>
- <title>Decide What to Change</title>
- <para>Using IDs in the "reRender" attribute to define
"AJAX zones" for update works fine in
- many cases.
- </para>
- <para>But you can not use this approach if your page contains, e.g. a
<emphasis
role="bold"><property><f:verbatim></property></emphasis>
- tag and you wish to update its content on AJAX response.
- </para>
- <para>The problem with the <emphasis role="bold">
- <property><f:verbatim/></property>
- </emphasis> tag as described above is related to the
- value of the transientFlag of JSF components. If the value of this flag is
true, the
- component must not participate in state saving or restoring of process.
- </para>
- <para>In order to provide a solution to this kind of problems, Ajax4jsf uses
the concept of
- an output panel that is defined by the <emphasis role="bold">
- <property><a4j:outputPanel></property>
- </emphasis> tag. If you put a <emphasis
role="bold"><property><f:verbatim></property></emphasis>
- tag inside of the output panel, then the content of the <emphasis
role="bold">
- <property><f:verbatim/></property>
- </emphasis> tag and content of
- other panel's child tags could be updated on AJAX response. There are
two ways to
- control this:
- <itemizedlist>
- <listitem>
- By setting the "ajaxRendered" attribute value to
"true".
-</listitem>
- <listitem>
- By setting the "reRender" attribute value of an Action
Component to the output panel ID.
-</listitem>
- </itemizedlist>
- </para>
- </section>
- </section>
- <section id="RequestErrorsAndSessionExpirationHandling">
- <?dbhtml filename="RequestErrorsAndSessionExpirationHandling.html"?>
- <title>Request Errors and Session Expiration Handling</title>
- <para>Ajax4jsf allows to redefine standard handlers responsible for processing of
different exceptional situations. It helps to define own JavaScript, which is executed
when this situations occur.</para>
- <section id="RequestErrorsHandling">
- <?dbhtml filename="RequestErrorsHandling.html"?>
- <title>Request Errors Handling</title>
- <para>To execute your own code on the client in case of an error during AJAX
request, it's necessary to redefine the standard "A4J.AJAX.onError "
method:</para>
- <programlisting role="JAVA"><![CDATA[A4J.AJAX.onError =
function(req,status,message) {
- // Custom Developer Code
- };]]></programlisting>
- <para>The function defined this way accepts as parameters:</para>
- <itemizedlist>
- <listitem>req - a params string of a request that calls an
error</listitem>
- <listitem>status - the number of an error returned by the
server</listitem>
- <listitem>message - a default message for the given error</listitem>
- </itemizedlist>
- <para>Thus, it's possible to create your own handler that is called on
timeouts, inner server errors, and etc.</para>
- </section>
- <section id="SessionExpiredHandling">
- <?dbhtml filename="SessionExpiredHandling.html"?>
- <title>Session Expired Handling</title>
- <para>Beginning with Ajax4jsf version 1.0.5 it's possible to redefine
also the <emphasis role="italic">
- <property>"onExpired"</property>
- </emphasis> framework method that is called on the <emphasis
role="italic">
- <property>"Session Expiration"</property>
- </emphasis> event.</para>
- <programlisting role="JAVA"><![CDATA[A4J.AJAX.onExpired =
function(loc,expiredMsg){
- // Custom Developer Code
-};
-]]></programlisting>
-
-<para>Here the function receives in params:</para>
- <itemizedlist>
- <listitem>loc - URL of the current page (on demand can be updated)
</listitem>
- <listitem>expiredMsg - a default message on <emphasis
role="italic">
- <property>"Session Expiration"</property>
- </emphasis>event.</listitem>
- </itemizedlist>
-<note>
-<title>Note:</title>
-Until the version 1.0.5 the method can't be redefined on <emphasis
role="italic">
- <property>"Session Expiration"</property>,
- </emphasis> a confirmation dialog with a request for view reloading was always
called.
-</note>
- </section>
-</section>
-&FAQ;</chapter>
Copied: tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGusingAJAX.xml (from rev 163,
trunk/docs/userguide/en/modules/a4jUGusingAJAX.xml)
===================================================================
--- tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGusingAJAX.xml
(rev 0)
+++ tags/1_1_1_rc1/docs/userguide/en/modules/a4jUGusingAJAX.xml 2007-05-04 01:10:03 UTC
(rev 168)
@@ -0,0 +1,316 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter id="BasicConceptsOfTheAjax4jsfFramework"
xreflabel="BasicConceptsOfTheAjax4jsfFramework">
+ <?dbhtml filename="BasicConceptsOfTheAjax4jsfFramework.html"?>
+
+ <chapterinfo>
+ <keywordset>
+ <keyword>AjaxContainer</keyword>
+
+ <keyword>Request Processing</keyword>
+
+ <keyword>Ajax4jsf</keyword>
+ </keywordset>
+ </chapterinfo>
+
+ <title>Basic concepts of the Ajax4jsf Framework</title>
+ <section id="introToBasics">
+ <?dbhtml filename="introToBasics.html"?>
+ <title>Introduction</title>
+ <para>The framework is implemented as a component library which adds AJAX
capability into existing
+ pages, so you don't need to write any JavaScript code or to replace
existing
+ components with new AJAX widgets. <property>Ajax4jsf</property> enables
page-wide AJAX support instead of the
+ traditional component-wide support. So, you can define the event on the page that
+ invokes an AJAX request and the areas of the page that should be synchronized with
the JSF
+ Component Tree after the AJAX request changes the data on the server according to
the
+ events fired on the client.</para>
+ <para>Next Figure shows how it works:</para>
+ <figure>
+ <title>Request Processing flow</title>
+ </figure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/newpic1.jpg"/>
+ </imageobject>
+ </mediaobject>
+ <para><property>Ajax4jsf</property> allows to define (by means of
JSF tags) different parts of a JSF page you
+ wish to update with an AJAX request and provide a few options to send AJAX
requests to
+ the server. Also JSF page doesn't change from a
"regular" JSF
+ page and you don't need to write any JavaScript or XMLHttpRequest
objects by hands, everything is done automatically.</para>
+ </section>
+ <section id="ArchitectureOverview">
+ <?dbhtml filename="ArchitectureOverview.html"?>
+ <title>Architecture Overview</title>
+ <para>Next figure lists several important elements of the
<property>Ajax4jsf</property> framework</para>
+ <figure>
+ <title>Ajax4jsf component structure</title>
+ </figure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/newpic2.jpg"/>
+ </imageobject>
+ </mediaobject>
+ <formalpara>
+ <title>Ajax Filter.</title>
+ <para>To get all benefits of <property>Ajax4jsf</property>, you
should register an AJAX Filter in web.xml
+ file of your application.The AJAX Filter recognizes multiple request types. The
sequence diagram on Figure 3
+ shows the difference in processing of a "regular" JSF request and
an AJAX request.</para>
+ </formalpara>
+ <para>In the first case the whole JSF tree will be encoded,
+ in the second one option it depends on the "size" of the AJAX
region (you can define AJAX region
+ by using the <emphasis
role="bold"><property><a4j:region></property></emphasis>).
As you can see, in the second case the filter parses
+ the content of an AJAX response before sending it to the client side.</para>
+ <para>Have a look at the next picture to understand these two
ways:</para>
+ <figure>
+ <title>Request Processing sequence diagram</title>
+ </figure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/newpic3.jpg"/>
+ </imageobject>
+ </mediaobject>
+ <para>In both cases, the information about required static or dynamic resources
that your application
+ requests is registered in the ResourseBuilder class.</para>
+ <para>When a request for a resource comes (Figure 4), the AJAX filter checks
the Resource Cache
+ for this resource and if it is there, the resource will be sent to the client.
Otherwise,
+ the filter will search for the resource among those that are registered by the
+ ResourceBuilder. If the resource is registered, the AJAX filter will send a request
to the
+ ResourceBuilder to create (deliver) the resource.</para>
+ <para>Next Figure shows the ways of resource request processing.</para>
+ <figure>
+ <title>Resource request sequence diagram</title>
+ </figure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/newpic4.jpg"/>
+ </imageobject>
+ </mediaobject>
+ <formalpara>
+ <title>AJAX Action Components</title>
+ <para>
+ There are four AJAX Action Components: AjaxCommandButton, AjaxCommandLink,
AjaxPoll and AjaxSupport.
+ You can use them to send AJAX requests from the client side.
+ </para>
+ </formalpara>
+ <formalpara>
+ <title>AJAX Containers</title>
+ <para>
+ AjaxContainer is an interface that describes an area on your JSF page that should
be decoded
+ during an AJAX request. AjaxViewRoot and AjaxRegion are implementations of this
interface.
+ </para>
+ </formalpara>
+ <formalpara>
+ <title>JavaScript Engine</title>
+ <para><property> Ajax4jsf</property> JavaScript Engine runs on
the client-side. It knows how to update different areas
+ on your JSF page based on the information from the Ajax response. Do
+ not use this JavaScript code directly, as it is available automatically.
+ </para>
+ </formalpara>
+ </section>
+ <section id="LimitationsAndRules">
+ <?dbhtml filename="LimitationAndRules.html"?>
+ <title>Limitations and Rules</title>
+ <para>In order to create AJAX JSF applications properly, keep the following
points in mind:</para>
+ <itemizedlist>
+ <listitem>
+ The AJAX framework should not append or delete, but only replace elements on the
page. For successful updates, an element with the same ID as in the response must exist on
the page. If you'd like to append any code to a page, put in a placeholder for it
(any empty element). For the same reason, it's recommended to place messages in
the<emphasis role="italic">
+ <property>"AjaxOutput"</property>
+ </emphasis> component (as no messages is also a message).
+ </listitem>
+ <listitem>
+ Don't use <emphasis role="bold">
+ <property><f:verbatim></property>
+ </emphasis> for self-rendered containers, since this component is
transient and not saved in the tree.
+ </listitem>
+ <listitem>
+ AJAX requests are made by XMLHttpRequest functions in XML format, but this XML
bypasses most validations and the corrections that might be made in a browser. So, create
only strict standards-compliant code for HTML and XHTML, without skipping any required
elements or attributes. Any necessary XML corrections are automatically made by the XML
filter on the server, but lot's of unexpected effects can be produced by an
incorrect HTML code.
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section id="HowTo...">
+ <?dbhtml filename="HowTo.html"?>
+ <title>How To...</title>
+ <section id="SendAnAJAXRequest">
+ <?dbhtml filename="SendAnAJAXRequest.html"?>
+ <title>Send an AJAX request</title>
+ <para>There are different ways to send AJAX requests from your JSF page. You
may use
+ <emphasis
role="bold"><property><a4j:commandButton></property></emphasis>,
<emphasis role="bold">
+ <property><a4j:commandLink></property>, <emphasis
role="bold"><property><a4j:poll></property></emphasis>
+ </emphasis> or <emphasis role="bold">
+ <property><a4j:support></property>
+ </emphasis> tags.
+ </para>
+ <para>All these tags hide the usual JavaScript activities that are required
for an XMHttpRequest
+ object building and an AJAX request sending. Also, they allow you to decide
which components of
+ your JSF page are to be re-rendered as a result of the AJAX response (you can
list the
+ IDs of these components in the "reRender" attribute).
+ </para>
+ <para>
+ <emphasis role="bold">
+ <property><a4j:commandButton></property>
+ </emphasis> and <emphasis role="bold">
+ <property><a4j:commandLink></property>
+ </emphasis> tags are used to send an AJAX
+ request on "onclick" JavaScript event.
+ </para>
+ <para>
+ <emphasis role="bold">
+ <property><a4j:poll></property>
+ </emphasis> tag are used to send an AJAX
+ request periodically using timer.
+ </para>
+ <para>The <emphasis role="bold">
+ <property><a4j:support></property>
+ </emphasis> tag allows you to add AJAX functionality to standard JSF
components
+ and send AJAX request onto a chosen JavaScript event:
"onkeyup", "onmouseover",
+ etc.
+ </para>
+ <para>Most important attributes of components that provide AJAX request
calling features are:</para>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="italic">
+ <property>"reRender"</property>
+ </emphasis>attribute as it was mentioned before specifies components to
be reRendered
+ after AJAX response. The attribute can be specified using EL expression and
formed dynamicaly on the
+ server side (see <ulink url="index.html#FAQ">FAQ
chapter</ulink>).
+ </listitem>
+ <listitem>
+ <emphasis role="italic">
+ <property>"RequestDelay"</property>
+ </emphasis> attribute is used for a requests frequency regulation.
+ </listitem>
+ </itemizedlist>
+ <programlisting role="XML"><![CDATA[<h:inputText
size="50" value="#{bean.text}">
+ <a4j:support event="onkeyup" RequestDelay="3"/>
+</h:inputText>]]></programlisting>
+ <para>So every next request from the frequent keyboard events will be
delayed
+ on 3 ms to reduce the number of requests.
+ </para>
+ <itemizedlist>
+ <listitem>
+ <emphasis role="italic">
+ <property>"EventsQueue"</property>
+ </emphasis> is a queue that stores the next request.
+ </listitem>
+ <listitem>
+ <emphasis role="italic">
+ <property>"LimitToList"</property>
+ </emphasis> attribute is used to regulate updatable regions. Setting
+ it to true limits the updatable areas only to specified in
+ reRender list, in other case all Output Panels of the region are updated.
+ </listitem>
+ <listitem> <emphasis role="italic">
+ <property>"ajaxSingle"</property>
+ </emphasis> attributes specify regions to be sent with a request,
+ if "false" it is a full region, in other case
it's is only a control caused
+ event.
+</listitem>
+ </itemizedlist>
+ </section>
+ <section id="DecideWhatToSend">
+ <?dbhtml filename="DecideWhatToSend.html"?>
+ <title>Decide What to Send</title>
+ <para>You may describe a region on the page you wish to send to the server,
in this way you can
+ control what part of the JSF View is decoded on the server side when you send
an
+ AJAX request.
+ </para>
+ <para>The easiest way to describe an AJAX region on your JSF page is to do
nothing,
+ because the content between the <emphasis role="bold">
+ <property><f:view></property>
+ </emphasis> and <emphasis role="bold">
+ <property></f:view></property>
+ </emphasis> tags is considered
+ the default AJAX region.
+ </para>
+ <para>You may define multiple AJAX regions on the JSF page (they can even be
nested) by using
+ the <emphasis role="bold">
+ <property><a4j:region></property>
+ </emphasis> tag.
+ </para>
+ <para>If you wish to render the content of AJAX response outside of the
active region then
+ the value of the "renderRegionOnly" attribute should be set
to "false". Otherwise, your
+ AJAX updates are limited to elements of the active region.
+ </para>
+ </section>
+ <section id="DecideWhatToChange">
+ <?dbhtml filename="DecideWhatToChange.html"?>
+ <title>Decide What to Change</title>
+ <para>Using IDs in the "reRender" attribute to define
"AJAX zones" for update works fine in
+ many cases.
+ </para>
+ <para>But you can not use this approach if your page contains, e.g. a
<emphasis
role="bold"><property><f:verbatim></property></emphasis>
+ tag and you wish to update its content on AJAX response.
+ </para>
+ <para>The problem with the <emphasis role="bold">
+ <property><f:verbatim/></property>
+ </emphasis> tag as described above is related to the
+ value of the transientFlag of JSF components. If the value of this flag is
true, the
+ component must not participate in state saving or restoring of process.
+ </para>
+ <para>In order to provide a solution to this kind of problems, Ajax4jsf uses
the concept of
+ an output panel that is defined by the <emphasis role="bold">
+ <property><a4j:outputPanel></property>
+ </emphasis> tag. If you put a <emphasis
role="bold"><property><f:verbatim></property></emphasis>
+ tag inside of the output panel, then the content of the <emphasis
role="bold">
+ <property><f:verbatim/></property>
+ </emphasis> tag and content of
+ other panel's child tags could be updated on AJAX response. There are
two ways to
+ control this:
+ <itemizedlist>
+ <listitem>
+ By setting the "ajaxRendered" attribute value to
"true".
+</listitem>
+ <listitem>
+ By setting the "reRender" attribute value of an Action
Component to the output panel ID.
+</listitem>
+ </itemizedlist>
+ </para>
+ </section>
+ </section>
+ <section id="RequestErrorsAndSessionExpirationHandling">
+ <?dbhtml filename="RequestErrorsAndSessionExpirationHandling.html"?>
+ <title>Request Errors and Session Expiration Handling</title>
+ <para>Ajax4jsf allows to redefine standard handlers responsible for processing of
different exceptional situations. It helps to define own JavaScript, which is executed
when this situations occur.</para>
+ <section id="RequestErrorsHandling">
+ <?dbhtml filename="RequestErrorsHandling.html"?>
+ <title>Request Errors Handling</title>
+ <para>To execute your own code on the client in case of an error during AJAX
request, it's necessary to redefine the standard "A4J.AJAX.onError "
method:</para>
+ <programlisting role="JAVA"><![CDATA[A4J.AJAX.onError =
function(req,status,message) {
+ // Custom Developer Code
+};]]></programlisting>
+ <para>The function defined this way accepts as parameters:</para>
+ <itemizedlist>
+ <listitem>req - a params string of a request that calls an
error</listitem>
+ <listitem>status - the number of an error returned by the
server</listitem>
+ <listitem>message - a default message for the given error</listitem>
+ </itemizedlist>
+ <para>Thus, it's possible to create your own handler that is called on
timeouts, inner server errors, and etc.</para>
+ </section>
+ <section id="SessionExpiredHandling">
+ <?dbhtml filename="SessionExpiredHandling.html"?>
+ <title>Session Expired Handling</title>
+ <para>Beginning with Ajax4jsf version 1.0.5 it's possible to redefine
also the <emphasis role="italic">
+ <property>"onExpired"</property>
+ </emphasis> framework method that is called on the <emphasis
role="italic">
+ <property>"Session Expiration"</property>
+ </emphasis> event.</para>
+ <programlisting role="JAVA"><![CDATA[A4J.AJAX.onExpired =
function(loc,expiredMsg){
+ // Custom Developer Code
+};
+]]></programlisting>
+
+<para>Here the function receives in params:</para>
+ <itemizedlist>
+ <listitem>loc - URL of the current page (on demand can be updated)
</listitem>
+ <listitem>expiredMsg - a default message on <emphasis
role="italic">
+ <property>"Session Expiration"</property>
+ </emphasis>event.</listitem>
+ </itemizedlist>
+<note>
+<title>Note:</title>
+Until the version 1.0.5 the method can't be redefined on <emphasis
role="italic">
+ <property>"Session Expiration"</property>,
+ </emphasis> a confirmation dialog with a request for view reloading was always
called.
+</note>
+ </section>
+</section>
+&FAQ;</chapter>
Deleted: tags/1_1_1_rc1/framework/pom.xml
===================================================================
--- trunk/framework/pom.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ tags/1_1_1_rc1/framework/pom.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -1,328 +0,0 @@
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>master</artifactId>
- <groupId>org.ajax4jsf</groupId>
- <version>1.1.1-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.ajax4jsf</groupId>
- <artifactId>ajax4jsf</artifactId>
- <name>Java Server Faces AJAX framework</name>
- <
url>http://labs.jboss.com/wiki/Ajax4jsf/framework</url>
- <properties>
- <jsfVersion>1.1</jsfVersion>
- </properties>
- <build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- <resource>
- <directory>target/javascript</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.ajax4jsf.cdk</groupId>
- <artifactId>maven-cdk-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <library>
- <prefix>org.ajax4jsf</prefix>
- <jsfVersion>${jsfVersion}</jsfVersion>
- <taglib>
- <uri>
-
https://ajax4jsf.dev.java.net/ajax
- </uri>
- <shortName>a4j</shortName>
- </taglib>
- </library>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-resources</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <ant antfile="${basedir}/generatescript.xml"
inheritRefs="true">
- <target name="assembly" />
- <property name="target-dir"
value="${project.build.directory}/javascript">
- </property>
- </ant>
- </tasks>
- <resourceRoot>
- ${project.build.directory}/javascript
- </resourceRoot>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>net.sourceforge.maven-taglib</groupId>
- <artifactId>maven-taglib-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>opensymphony</groupId>
- <artifactId>oscache</artifactId>
- <version>2.3</version>
- </dependency>
- <dependency>
- <groupId>com.sun.facelets</groupId>
- <artifactId>jsf-facelets</artifactId>
- <version>1.1.11</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>nekohtml</groupId>
- <artifactId>nekohtml</artifactId>
- <version>0.9.5</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>net.sf.json-lib</groupId>
- <artifactId>json-lib</artifactId>
- <version>0.9</version>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </exclusion>
- <exclusion>
- <groupId>xom</groupId>
- <artifactId>xom</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.7.0</version>
- </dependency>
- <dependency>
- <groupId>commons-digester</groupId>
- <artifactId>commons-digester</artifactId>
- <version>1.8</version>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2</version>
- </dependency>
- </dependencies>
- <profiles>
- <profile>
- <id>jsf1_1</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- <property>
- <name>jsfVersion</name>
- <value>1.1</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- <version>1.1_02</version>
- <exclusions>
- <!-- No longer presented in any repo -->
- <exclusion>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.servlet.jsp.jstl</groupId>
- <artifactId>jstl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- <version>1.1_02</version>
- <scope>runtime</scope>
- <exclusions>
- <!-- No longer presented in any repo -->
- <exclusion>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.servlet.jsp.jstl</groupId>
- <artifactId>jstl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>jsf1_2</id>
- <activation>
- <property>
- <name>jsfVersion</name>
- <value>1.2</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <!-- append JSF 1.2 related sources -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>process-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>
- src/main/jsf12
- </source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- <version>1.2_03</version>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- <version>1.2_03</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>assembly</id>
- <build>
- <plugins>
- <plugin>
- <groupId>net.sourceforge.maven-taglib</groupId>
- <artifactId>maven-taglib-plugin</artifactId>
- <configuration>
- <taglib.src.dir>
- ${project.build.directory}/generated-component/resources/META-INF
- </taglib.src.dir>
- <tldDocDir>
- ${project.build.directory}/tlddoc
- </tldDocDir>
- </configuration>
-
- <executions>
- <execution>
- <id>attach-javadoc</id>
- <goals>
- <goal>taglibdocjar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
Copied: tags/1_1_1_rc1/framework/pom.xml (from rev 164, trunk/framework/pom.xml)
===================================================================
--- tags/1_1_1_rc1/framework/pom.xml (rev 0)
+++ tags/1_1_1_rc1/framework/pom.xml 2007-05-04 01:10:03 UTC (rev 168)
@@ -0,0 +1,343 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>master</artifactId>
+ <groupId>org.ajax4jsf</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.ajax4jsf</groupId>
+ <artifactId>ajax4jsf</artifactId>
+ <name>Java Server Faces AJAX framework</name>
+ <
url>http://labs.jboss.com/wiki/Ajax4jsf/framework</url>
+ <properties>
+ <jsfVersion>1.1</jsfVersion>
+ </properties>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <directory>target/javascript</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.ajax4jsf.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <library>
+ <prefix>org.ajax4jsf</prefix>
+ <jsfVersion>${jsfVersion}</jsfVersion>
+ <taglib>
+ <uri>
+
https://ajax4jsf.dev.java.net/ajax
+ </uri>
+ <shortName>a4j</shortName>
+ </taglib>
+ </library>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <ant
+ antfile="${basedir}/generatescript.xml"
inheritRefs="true">
+ <target name="assembly" />
+ <property name="target-dir"
+ value="${project.build.directory}/javascript">
+ </property>
+ </ant>
+ </tasks>
+ <resourceRoot>
+ ${project.build.directory}/javascript
+ </resourceRoot>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-source</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>net.sourceforge.maven-taglib</groupId>
+ <artifactId>maven-taglib-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>oscache</artifactId>
+ <version>2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.facelets</groupId>
+ <artifactId>jsf-facelets</artifactId>
+ <version>1.1.11</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>nekohtml</groupId>
+ <artifactId>nekohtml</artifactId>
+ <version>0.9.5</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.json-lib</groupId>
+ <artifactId>json-lib</artifactId>
+ <version>0.9</version>
+ <optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xom</groupId>
+ <artifactId>xom</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <version>1.8</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2</version>
+ </dependency>
+ </dependencies>
+ <profiles>
+ <profile>
+ <id>jsf1_1</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ <property>
+ <name>jsfVersion</name>
+ <value>1.1</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.1_02</version>
+ <exclusions>
+ <!-- No longer presented in any repo -->
+ <exclusion>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet.jsp.jstl</groupId>
+ <artifactId>jstl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.1_02</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <!-- No longer presented in any repo -->
+ <exclusion>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet.jsp.jstl</groupId>
+ <artifactId>jstl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>jsf1_2</id>
+ <activation>
+ <property>
+ <name>jsfVersion</name>
+ <value>1.2</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <!-- append JSF 1.2 related sources -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>
+ build-helper-maven-plugin
+ </artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/main/jsf12</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.2_03</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.2_03</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>assembly</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>net.sourceforge.maven-taglib</groupId>
+ <artifactId>maven-taglib-plugin</artifactId>
+ <configuration>
+ <taglib.src.dir>
+ ${project.build.directory}/generated-component/resources/META-INF
+ </taglib.src.dir>
+ <tldDocDir>
+ ${project.build.directory}/tlddoc
+ </tldDocDir>
+ </configuration>
+
+ <executions>
+ <execution>
+ <id>attach-javadoc</id>
+ <goals>
+ <goal>taglibdocjar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
\ No newline at end of file
Copied: tags/1_1_1_rc1/framework/src/main/config/component/push.xml (from rev 164,
trunk/framework/src/main/config/component/push.xml)
===================================================================
--- tags/1_1_1_rc1/framework/src/main/config/component/push.xml
(rev 0)
+++ tags/1_1_1_rc1/framework/src/main/config/component/push.xml 2007-05-04 01:10:03 UTC
(rev 168)
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components
+ PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
+ "https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd" [
+<!ENTITY universal_html_attributes SYSTEM
"html_universal_attributes.xml">
+]>
+
+<components>
+ <component>
+ <name>org.ajax4jsf.ajax.Push</name>
+ <family>org.ajax4jsf.components.AjaxPush</family>
+ <classname>org.ajax4jsf.ajax.html.AjaxPush</classname>
+ <superclass>org.ajax4jsf.ajax.UIPush</superclass>
+ <description>
+ Periodically perform AJAX request to server, to simulate
+ 'push' data.
+ <br />
+ </description>
+ <displayname>Ajax Push</displayname>
+ <icon>icon</icon>
+ <renderer generate="false" override="false">
+ <name>org.ajax4jsf.components.AjaxPushRenderer</name>
+ <classname>
+ org.ajax4jsf.renderkit.html.AjaxPushRenderer
+ </classname>
+ <!--
+ <superclass>javax.faces.renderer.Renderer</superclass>
+ -->
+ <description>
+ Perform functions for decoding AJAX requests and
+ building client script for events.
+ </description>
+ <displayname>renderer for Ajax Push</displayname>
+ <icon>icon</icon>
+ </renderer>
+ <tag>
+ <name>push</name>
+ <classname>org.ajax4jsf.taglib.ajax.AjaxPushTag</classname>
+ <superclass>
+ org.ajax4jsf.framework.taglib.UIComponentTagBase
+ </superclass>
+ <displayname>Ajax Push</displayname>
+ <icon>icon</icon>
+ </tag>
+ <taghandler generate="true">
+ <classname>org.ajax4jsf.taglib.html.facelets.AjaxPushHandler</classname>
+ <superclass>org.ajax4jsf.taglib.html.facelets.AjaxComponentHandler</superclass>
+ </taghandler>
+ &ui_component_attributes;
+ &ui_command_attributes;
+ &ajax_component_attributes;
+ <property elonly="true" attachedstate="true">
+ <name>eventProducer</name>
+ <classname>javax.faces.el.MethodBinding</classname>
+ <description>
+ MethodBinding pointing at method accepting an PushEventListener with return
type void.
+ User bean must register this listener and send EventObject to this listener
on ready.
+ </description>
+ <methodargs>java.util.EventListener.class</methodargs>
+ </property>
+ <property>
+ <name>onsubmit</name>
+ <classname>java.lang.String</classname>
+ <description>
+ JavaScript code for call before submission of ajax
+ event
+ </description>
+ </property>
+ <property>
+ <name>interval</name>
+ <classname>int</classname>
+ <description>
+ Interval (in ms) for call push requests. Default value
+ 1000 (1 sec)
+ </description>
+ </property>
+ <property>
+ <name>enabled</name>
+ <classname>boolean</classname>
+ <description>
+ <![CDATA[Enable/disable pushing]]>
+ </description>
+ <defaultvalue>true</defaultvalue>
+ </property>
+ <property hidden="true">
+ <name>value</name>
+ <classname>java.lang.Object</classname>
+ </property>
+ <property hidden="true">
+ <name>submitted</name>
+ <classname>boolean</classname>
+ </property>
+ <property hidden="true">
+ <name>requestDelay</name>
+ <classname>int</classname>
+ </property>
+ <property>
+ <name>ignoreDupResponses</name>
+ <classname>boolean</classname>
+ <description>If true, unfinished request will be aborted on new
event.</description>
+ </property>
+ <property>
+ <name>timeout</name>
+ <classname>int</classname>
+ <description>Timeout (in ms) for request</description>
+ </property>
+ </component>
+</components>
\ No newline at end of file
Copied: tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/PushEventListener.java
(from rev 164, trunk/framework/src/main/java/org/ajax4jsf/ajax/PushEventListener.java)
===================================================================
--- tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/PushEventListener.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/PushEventListener.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,10 @@
+package org.ajax4jsf.ajax;
+
+import java.util.EventListener;
+import java.util.EventObject;
+
+public interface PushEventListener extends EventListener {
+
+ public void onEvent(EventObject event);
+
+}
Copied: tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java
(from rev 166, trunk/framework/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java)
===================================================================
--- tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,32 @@
+package org.ajax4jsf.ajax;
+
+import java.io.Serializable;
+import java.util.EventObject;
+
+public class PushEventsCounter implements PushEventListener,Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4060284352186710009L;
+ private volatile boolean performed = false;
+
+ public void onEvent(EventObject event) {
+ performed = true;
+ }
+
+ /**
+ * @return the performed
+ */
+ public boolean isPerformed() {
+ return performed;
+ }
+
+ /**
+ */
+ public void processed() {
+ this.performed = false;
+ }
+
+
+}
Deleted: tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java 2007-05-02 17:40:09
UTC (rev 158)
+++ tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -1,251 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Set;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIPanel;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
-
-import org.ajax4jsf.framework.ajax.AjaxContainer;
-import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.AjaxListener;
-import org.ajax4jsf.framework.ajax.AjaxRegionBrige;
-import org.ajax4jsf.framework.ajax.AjaxViewRoot;
-import org.ajax4jsf.framework.ajax.InvokerCallback;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/08 15:02:06 $
- *
- */
-public abstract class UIAjaxRegion extends UIPanel implements AjaxContainer {
-
- private AjaxRegionBrige brige;
-
- public static final String COMPONENT_TYPE =
"org.ajax4jsf.components.AjaxRegion";
-
- /**
- *
- */
- public UIAjaxRegion() {
- brige = new AjaxRegionBrige(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
- */
-// public void encodeBegin(FacesContext context) throws IOException {
-// UIViewRoot root = context.getViewRoot();
-// if (root instanceof AjaxViewRoot) {
-// ((AjaxViewRoot) root).addAjaxRegion(this);
-// }
-// super.encodeBegin(context);
-// }
-
- private InvokerCallback _ajaxInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- try {
- if (component instanceof AjaxContainer) {
- AjaxContainer ajax = (AjaxContainer) component;
- ajax.encodeAjax(context);
- } else {
- // Container not found, use Root for encode.
- encodeAjax(context);
- }
- } catch (IOException e) {
- throw new FacesException(e);
- }
- }
-
- public void invokeRoot(FacesContext context) {
- try {
- encodeAjax(context);
- } catch (IOException e) {
- throw new FacesException(e);
- }
- }
- };
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
- */
- public void encodeChildren(FacesContext context) throws IOException {
- // If this region is single child of ViewRoot, encode Ajax response for
- // submitted container.
- UIViewRoot viewRoot = context.getViewRoot();
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- if ( (getParent() == viewRoot) &&
- (viewRoot instanceof AjaxViewRoot) &&
- ((AjaxViewRoot) viewRoot).isHavePage() &&
- (ajaxContext.isAjaxRequest())) {
- AjaxContext.invokeOnRegionOrRoot((AjaxViewRoot) viewRoot, context, _ajaxInvoker,
- PhaseId.RENDER_RESPONSE);
- } else {
- super.encodeChildren(context);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#broadcast(javax.faces.event.FacesEvent)
- */
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- super.broadcast(event);
- brige.broadcast(event);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#getAjaxListener()
- */
- public MethodBinding getAjaxListener() {
- return brige.getAjaxListener();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isImmediate()
- */
- public boolean isImmediate() {
- return brige.isImmediate();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSubmitted()
- */
- public boolean isSubmitted() {
- return brige.isSubmitted();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#restoreState(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
- Object[] mystate = (Object[]) state;
- super.restoreState(context, mystate[0]);
- brige.restoreState(context, mystate[1]);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- Object[] state = new Object[2];
- state[0] = super.saveState(context);
- state[1] = brige.saveState(context);
- return state;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#setAjaxListener(javax.faces.el.MethodBinding)
- */
- public void setAjaxListener(MethodBinding ajaxListener) {
- brige.setAjaxListener(ajaxListener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setImmediate(boolean)
- */
- public void setImmediate(boolean immediate) {
- brige.setImmediate(immediate);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSubmitted(boolean)
- */
- public void setSubmitted(boolean submitted) {
- brige.setSubmitted(submitted);
- }
-
- public void addAjaxListener(AjaxListener listener) {
- addFacesListener(listener);
- }
-
- public AjaxListener[] getAjaxListeners() {
- return (AjaxListener[]) getFacesListeners(AjaxListener.class);
- }
-
- public void removeAjaxListener(AjaxListener listener) {
- removeFacesListener(listener);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSelfRendered()
- */
- public boolean isSelfRendered() {
- return brige.isSelfRendered();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSelfRendered(boolean)
- */
- public void setSelfRendered(boolean selfRendered) {
- brige.setSelfRendered(selfRendered);
- }
-
- public void encodeAjax(FacesContext context) throws IOException {
- String rendererType = getRendererType();
- if (rendererType != null) {
- ((AjaxContainerRenderer) getRenderer(context)).encodeAjax(context,
- this);
- }
-
- }
-
-}
Copied: tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java (from
rev 164, trunk/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java)
===================================================================
--- tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java
(rev 0)
+++ tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxRegion.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,249 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIPanel;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+
+import org.ajax4jsf.framework.ajax.AjaxContainer;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxListener;
+import org.ajax4jsf.framework.ajax.AjaxRegionBrige;
+import org.ajax4jsf.framework.ajax.AjaxViewRoot;
+import org.ajax4jsf.framework.ajax.InvokerCallback;
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/08 15:02:06 $
+ *
+ */
+public abstract class UIAjaxRegion extends UIPanel implements AjaxContainer {
+
+ private AjaxRegionBrige brige;
+
+ public static final String COMPONENT_TYPE =
"org.ajax4jsf.components.AjaxRegion";
+
+ /**
+ *
+ */
+ public UIAjaxRegion() {
+ brige = new AjaxRegionBrige(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
+ */
+// public void encodeBegin(FacesContext context) throws IOException {
+// UIViewRoot root = context.getViewRoot();
+// if (root instanceof AjaxViewRoot) {
+// ((AjaxViewRoot) root).addAjaxRegion(this);
+// }
+// super.encodeBegin(context);
+// }
+
+ private InvokerCallback _ajaxInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ try {
+ if (component instanceof AjaxContainer) {
+ AjaxContainer ajax = (AjaxContainer) component;
+ ajax.encodeAjax(context);
+ } else {
+ // Container not found, use Root for encode.
+ encodeAjax(context);
+ }
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ public void invokeRoot(FacesContext context) {
+ try {
+ encodeAjax(context);
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+ }
+ };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
+ */
+ public void encodeChildren(FacesContext context) throws IOException {
+ // If this region is single child of ViewRoot, encode Ajax response for
+ // submitted container.
+ UIViewRoot viewRoot = context.getViewRoot();
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ if ( (getParent() == viewRoot) &&
+ (viewRoot instanceof AjaxViewRoot) &&
+ ((AjaxViewRoot) viewRoot).isHavePage() &&
+ (ajaxContext.isAjaxRequest())) {
+ AjaxContext.invokeOnRegionOrRoot((AjaxViewRoot) viewRoot, context, _ajaxInvoker);
+ } else {
+ super.encodeChildren(context);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+ brige.broadcast(event);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#getAjaxListener()
+ */
+ public MethodBinding getAjaxListener() {
+ return brige.getAjaxListener();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isImmediate()
+ */
+ public boolean isImmediate() {
+ return brige.isImmediate();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSubmitted()
+ */
+ public boolean isSubmitted() {
+ return brige.isSubmitted();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#restoreState(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state) {
+ Object[] mystate = (Object[]) state;
+ super.restoreState(context, mystate[0]);
+ brige.restoreState(context, mystate[1]);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[2];
+ state[0] = super.saveState(context);
+ state[1] = brige.saveState(context);
+ return state;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#setAjaxListener(javax.faces.el.MethodBinding)
+ */
+ public void setAjaxListener(MethodBinding ajaxListener) {
+ brige.setAjaxListener(ajaxListener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setImmediate(boolean)
+ */
+ public void setImmediate(boolean immediate) {
+ brige.setImmediate(immediate);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSubmitted(boolean)
+ */
+ public void setSubmitted(boolean submitted) {
+ brige.setSubmitted(submitted);
+ }
+
+ public void addAjaxListener(AjaxListener listener) {
+ addFacesListener(listener);
+ }
+
+ public AjaxListener[] getAjaxListeners() {
+ return (AjaxListener[]) getFacesListeners(AjaxListener.class);
+ }
+
+ public void removeAjaxListener(AjaxListener listener) {
+ removeFacesListener(listener);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSelfRendered()
+ */
+ public boolean isSelfRendered() {
+ return brige.isSelfRendered();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSelfRendered(boolean)
+ */
+ public void setSelfRendered(boolean selfRendered) {
+ brige.setSelfRendered(selfRendered);
+ }
+
+ public void encodeAjax(FacesContext context) throws IOException {
+ String rendererType = getRendererType();
+ if (rendererType != null) {
+ ((AjaxContainerRenderer) getRenderer(context)).encodeAjax(context,
+ this);
+ }
+
+ }
+
+}
Deleted: tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java 2007-05-02 17:40:09
UTC (rev 158)
+++ tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -1,229 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.io.Serializable;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.framework.ajax.AjaxActionComponent;
-import org.ajax4jsf.framework.ajax.AjaxSupport;
-import org.ajax4jsf.framework.ajax.EventValueBinding;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Component for append ajax functions to any control component.
- * Append action functionality to non-action control,
- * setup javascript events for parent component,
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:52 $
- *
- */
-public abstract class UIAjaxSupport extends AjaxActionComponent implements AjaxSupport
-{
-
- //~ Static fields/initializers ---------------------------------------------
-
- public static final String COMPONENT_TYPE = "org.ajax4jsf.ajax.Support";
- public static final String COMPONENT_FAMILY = "javax.faces.Command";
- public static final String DEFAULT_RENDERER_TYPE =
"org.ajax4jsf.components.AjaxSupportRenderer";
- public static final String AJAX_SUPPORT_SET =
"com.exadel.components.ajax.support.";
- private static final Log log = LogFactory.getLog(UIAjaxSupport.class);
-
- /**
- * Name of JavaScript function, called before submit Ajax request
- * description
- * @parameter
- * @return the acceptClass
- */
- public abstract String getOnsubmit();
-
- /**
- * @param newOnsubmit the value to set
- */
- public abstract void setOnsubmit(String newOnsubmit);
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponentBase#setValueBinding(java.lang.String,
javax.faces.el.ValueBinding)
- */
- public void setValueBinding(String arg0, ValueBinding arg1) {
- // var - not allowed name. must be literal.
- if("var".equals(arg0)){
- throw new FacesException(
- Messages.getMessage(Messages.VAR_MUST_BE_LITERAL, getClientId(getFacesContext())));
- }
- if("event".equals(arg0)){
- throw new FacesException(
- Messages.getMessage(Messages.EVENT_MUST_BE_LITERAL,
getClientId(getFacesContext())));
- }
- super.setValueBinding(arg0, arg1);
- }
-
- /**
- * Create Special <code>ValueBinding</code> for build JavaScrept
- * event code in parent component from this.
- * @return <code>EventValueBinding</code> based on properties of current
component
- */
- private ValueBinding getEventValueBinding()
- {
- if (log.isDebugEnabled())
- {
- log.debug(Messages.getMessage(Messages.CREATE_JAVASCRIPT_EVENT, getId()));
- }
- return new EventValueBinding(this);
- }
-
- /**
- * @return JavaScript eventString. Rebuild on every call, since
- * can be in loop ( as in dataTable ) with different parameters.
- */
- public String getEventString()
- {
- StringBuffer buildOnEvent = new StringBuffer();
- String onsubmit = getOnsubmit();
- // Insert script to call before submit ajax request.
- if (null != onsubmit) {
- buildOnEvent.append(onsubmit).append(";");
- }
- // Due to JSF RI 1.1 bug, clear cached clientId
- setId(getId());
- buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this, getFacesContext(),
- getEvent()));
- String script = buildOnEvent.toString();
- return script;
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
- */
- public void decode(FacesContext context) {
- // Due to JSF RI 1.1 bug, clear cached clientId
- setId(getId());
- super.decode(context);
- }
-
- /**
- * After nornal setting <code>parent</code> property in case of
- * created component set Ajax properties for parent.
- * @see
javax.faces.component.UIComponentBase#setParent(javax.faces.component.UIComponent)
- */
- public void setParent(UIComponent parent)
- {
- super.setParent(parent);
- if (null != parent && parent.getFamily() != null ) {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.CALLED_SET_PARENT,
parent.getClass().getName()));
- }
- // TODO If this comopnent configured, set properties for parent component.
- // NEW created component have parent, restored view - null in My faces.
- // and SUN RI not call at restore saved view.
- // In other case - set in restoreState method.
- // if (parent.getParent() != null)
- {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.DETECT_NEW_COMPONENT));
- }
- setParentProperties(parent);
-
- }
- }
- }
-
- public void setParentProperties(UIComponent parent) {
- ValueBinding valueBinding;
-// Map parentAttributes = parent.getAttributes();
-/* if (parent instanceof ActionSource && null == getEvent())
- {
- log.debug("Set properties for parent as ActionSource");
- // Translate AJAX properties to parent component.
- if (_reRender != null)
- {
- parentAttributes
- .put(AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE,
- _reRender);
- }
- else if ((valueBinding = getValueBinding("reRender")) != null)
- {
- parent.setValueBinding(
- AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE,
- valueBinding);
- }
- if (_oncomplete != null)
- {
- parentAttributes
- .put(AjaxRendererUtils.ONCOMPLETE_ATTR_NAME,
- _oncomplete);
- }
- else if ((valueBinding = getValueBinding("oncomplete")) != null)
- {
- parent.setValueBinding(
- AjaxRendererUtils.ONCOMPLETE_ATTR_NAME,
- valueBinding);
- }
- if (_status != null)
- {
- parentAttributes.put(AjaxRendererUtils.STATUS_ATTR_NAME,
- _status);
- }
- else if ((valueBinding = getValueBinding("status")) != null)
- {
- parent.setValueBinding(AjaxRendererUtils.STATUS_ATTR_NAME,
- valueBinding);
- }
- if (_limitToListSet)
- {
- parentAttributes.put(
- AjaxRendererUtils.LIMITTOLIST_ATTR_NAME, Boolean
- .valueOf(_limitToList));
- }
- else if ((valueBinding = getValueBinding("limitToList")) != null)
- {
- parent.setValueBinding(
- AjaxRendererUtils.LIMITTOLIST_ATTR_NAME,
- valueBinding);
- }
- // Add Listener for all supported types.
- AjaxRegionListener listener = new AjaxRegionListener();
- ((ActionSource) parent).addActionListener(listener);
- }
- else*/ if (null != getEvent())
- {
- if (log.isDebugEnabled())
- {
- log.debug(Messages.getMessage(Messages.SET_VALUE_BINDING_FOR_EVENT,
getEvent()));
- }
- // for non action/data components, or for non-default events - build listener
for this instance.
- valueBinding = getEventValueBinding();
- // test for valid event attribute name.
- // TODO - test for compability with concrete element.
- parent.setValueBinding(getEvent(), valueBinding);
- }
-
- }
-
-}
Copied: tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java (from
rev 164, trunk/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java)
===================================================================
--- tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java
(rev 0)
+++ tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIAjaxSupport.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,233 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.io.Serializable;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.ajax4jsf.framework.ajax.AjaxActionComponent;
+import org.ajax4jsf.framework.ajax.AjaxSupport;
+import org.ajax4jsf.framework.ajax.EventValueBinding;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * Component for append ajax functions to any control component.
+ * Append action functionality to non-action control,
+ * setup javascript events for parent component,
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:52 $
+ *
+ */
+public abstract class UIAjaxSupport extends AjaxActionComponent implements AjaxSupport
+{
+
+ //~ Static fields/initializers ---------------------------------------------
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.ajax.Support";
+ public static final String COMPONENT_FAMILY = "javax.faces.Command";
+ public static final String DEFAULT_RENDERER_TYPE =
"org.ajax4jsf.components.AjaxSupportRenderer";
+ public static final String AJAX_SUPPORT_SET =
"com.exadel.components.ajax.support.";
+ private static final Log log = LogFactory.getLog(UIAjaxSupport.class);
+
+ /**
+ * Name of JavaScript function, called before submit Ajax request
+ * description
+ * @parameter
+ * @return the acceptClass
+ */
+ public abstract String getOnsubmit();
+
+ /**
+ * @param newOnsubmit the value to set
+ */
+ public abstract void setOnsubmit(String newOnsubmit);
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponentBase#setValueBinding(java.lang.String,
javax.faces.el.ValueBinding)
+ */
+ public void setValueBinding(String arg0, ValueBinding arg1) {
+ // var - not allowed name. must be literal.
+ if("var".equals(arg0)){
+ throw new FacesException(
+ Messages.getMessage(Messages.VAR_MUST_BE_LITERAL, getClientId(getFacesContext())));
+ }
+ if("event".equals(arg0)){
+ throw new FacesException(
+ Messages.getMessage(Messages.EVENT_MUST_BE_LITERAL,
getClientId(getFacesContext())));
+ }
+ super.setValueBinding(arg0, arg1);
+ }
+
+ /**
+ * Create Special <code>ValueBinding</code> for build JavaScrept
+ * event code in parent component from this.
+ * @return <code>EventValueBinding</code> based on properties of current
component
+ */
+ private ValueBinding getEventValueBinding()
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(Messages.getMessage(Messages.CREATE_JAVASCRIPT_EVENT, getId()));
+ }
+ return new EventValueBinding(this);
+ }
+
+ /**
+ * @return JavaScript eventString. Rebuild on every call, since
+ * can be in loop ( as in dataTable ) with different parameters.
+ */
+ public String getEventString()
+ {
+ StringBuffer buildOnEvent = new StringBuffer();
+ String onsubmit = getOnsubmit();
+ // Insert script to call before submit ajax request.
+ if (null != onsubmit) {
+ buildOnEvent.append(onsubmit).append(";");
+ }
+ // Due to JSF RI 1.1 bug, clear cached clientId
+ setId(getId());
+ buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this, getFacesContext(),
+ getEvent()));
+ String script = buildOnEvent.toString();
+ return script;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
+ */
+ public void decode(FacesContext context) {
+ // Due to JSF RI 1.1 bug, clear cached clientId
+ setId(getId());
+ super.decode(context);
+ }
+
+ /**
+ * After nornal setting <code>parent</code> property in case of
+ * created component set Ajax properties for parent.
+ * @see
javax.faces.component.UIComponentBase#setParent(javax.faces.component.UIComponent)
+ */
+ public void setParent(UIComponent parent)
+ {
+ super.setParent(parent);
+ if (null != parent && parent.getFamily() != null ) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.CALLED_SET_PARENT,
parent.getClass().getName()));
+ }
+ // TODO If this comopnent configured, set properties for parent component.
+ // NEW created component have parent, restored view - null in My faces.
+ // and SUN RI not call at restore saved view.
+ // In other case - set in restoreState method.
+ // if (parent.getParent() != null)
+ {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.DETECT_NEW_COMPONENT));
+ }
+ setParentProperties(parent);
+
+ }
+ }
+ }
+
+ public void setParentProperties(UIComponent parent) {
+ ValueBinding valueBinding;
+// Map parentAttributes = parent.getAttributes();
+/* if (parent instanceof ActionSource && null == getEvent())
+ {
+ log.debug("Set properties for parent as ActionSource");
+ // Translate AJAX properties to parent component.
+ if (_reRender != null)
+ {
+ parentAttributes
+ .put(AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE,
+ _reRender);
+ }
+ else if ((valueBinding = getValueBinding("reRender")) != null)
+ {
+ parent.setValueBinding(
+ AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE,
+ valueBinding);
+ }
+ if (_oncomplete != null)
+ {
+ parentAttributes
+ .put(AjaxRendererUtils.ONCOMPLETE_ATTR_NAME,
+ _oncomplete);
+ }
+ else if ((valueBinding = getValueBinding("oncomplete")) != null)
+ {
+ parent.setValueBinding(
+ AjaxRendererUtils.ONCOMPLETE_ATTR_NAME,
+ valueBinding);
+ }
+ if (_status != null)
+ {
+ parentAttributes.put(AjaxRendererUtils.STATUS_ATTR_NAME,
+ _status);
+ }
+ else if ((valueBinding = getValueBinding("status")) != null)
+ {
+ parent.setValueBinding(AjaxRendererUtils.STATUS_ATTR_NAME,
+ valueBinding);
+ }
+ if (_limitToListSet)
+ {
+ parentAttributes.put(
+ AjaxRendererUtils.LIMITTOLIST_ATTR_NAME, Boolean
+ .valueOf(_limitToList));
+ }
+ else if ((valueBinding = getValueBinding("limitToList")) != null)
+ {
+ parent.setValueBinding(
+ AjaxRendererUtils.LIMITTOLIST_ATTR_NAME,
+ valueBinding);
+ }
+ // Add Listener for all supported types.
+ AjaxRegionListener listener = new AjaxRegionListener();
+ ((ActionSource) parent).addActionListener(listener);
+ }
+ else*/ if (null != getEvent())
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(Messages.getMessage(Messages.SET_VALUE_BINDING_FOR_EVENT,
getEvent()));
+ }
+ // for non action/data components, or for non-default events - build listener
for this instance.
+ valueBinding = getEventValueBinding();
+ // test for valid event attribute name.
+ // TODO - test for compability with concrete element.
+ parent.setValueBinding(getEvent(), valueBinding);
+ }
+
+ }
+
+ protected UIComponent getSingleComponent() {
+ return getParent();
+ }
+
+}
Copied: tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIPush.java (from rev
165, trunk/framework/src/main/java/org/ajax4jsf/ajax/UIPush.java)
===================================================================
--- tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIPush.java
(rev 0)
+++ tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/ajax/UIPush.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,111 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.io.IOException;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.servlet.http.HttpSession;
+
+import org.ajax4jsf.framework.ajax.AjaxActionComponent;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.xmlfilter.PollEventsManager;
+
+/**
+ * Component for periodically call AJAX events on server ( poll actions )
+ * @author shura
+ *
+ */
+public abstract class UIPush extends AjaxActionComponent {
+
+ public static final String COMPONENT_TYPE="org.ajax4jsf.ajax.Push";
+
+
+ private transient boolean _submitted = false;
+
+ /**
+ * @return the submitted
+ */
+ public boolean isSubmitted() {
+ return _submitted;
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException {
+ MethodBinding producer = getEventProducer();
+ // Subscribe events producer to push status listener.
+ if(null != producer){
+ producer.invoke(context, new Object[]{getListener(context)});
+ }
+ super.encodeBegin(context);
+ }
+
+ private PushEventsCounter getListener(FacesContext context){
+ PollEventsManager eventsManeger = (PollEventsManager)
context.getExternalContext().getApplicationMap().get(PollEventsManager.EVENTS_MANAGER_KEY);
+ return eventsManeger.getListener(getListenerId(context));
+ }
+
+ public String getListenerId(FacesContext context){
+ Object session = context.getExternalContext().getSession(false);
+ StringBuffer id = new StringBuffer();
+ if(null != session && session instanceof HttpSession){
+ HttpSession httpSession = (HttpSession) session;
+ id.append(httpSession.getId());
+ }
+ id.append(context.getViewRoot().getViewId());
+ id.append(NamingContainer.SEPARATOR_CHAR);
+ id.append(getClientId(context));
+ return id.toString();
+ }
+ /**
+ * @param submitted the submitted to set
+ */
+ public void setSubmitted(boolean submitted) {
+ _submitted = submitted;
+ }
+
+ public abstract MethodBinding getEventProducer();
+
+ public abstract void setEventProducer(MethodBinding producer);
+ /**
+ * @return time in mc for polling interval.
+ */
+ public abstract int getInterval();
+
+ /**
+ * @param interval time in mc for polling interval.
+ */
+ public abstract void setInterval(int interval);
+
+ public abstract boolean isEnabled();
+
+ public abstract void setEnabled(boolean enable);
+
+ protected void setupReRender(FacesContext facesContext) {
+ super.setupReRender(facesContext);
+// AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(this);
+ //getListener(facesContext).processed();
+ }
+
+
+}
Deleted:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
===================================================================
---
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java 2007-05-02
17:40:09 UTC (rev 158)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -1,144 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
-
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:21 $
- *
- */
-public abstract class AjaxActionComponent extends UICommand implements
- AjaxComponent, AjaxSource {
-
- public static final String FOCUS_DATA_ID = "_A4J.AJAX.focus";
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
- */
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- // perform default
- super.broadcast(event);
- if (event instanceof AjaxEvent) {
- FacesContext context = getFacesContext();
- // complete re-Render fields. AjaxEvent deliver before render
- // response.
- setupReRender(context);
- // Put data for send in response
- Object data = getData();
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- if (null != data) {
- ajaxContext.setResponseData(data);
- }
- String focus = getFocus();
- if (null != focus) {
- // search for component in tree.
- // TODO - use more pourful search, as in h:outputLabel component.
- UIComponent focusComponent = findComponent(focus);
- if(null != focusComponent){
- focus = focusComponent.getClientId(context);
- }
- ajaxContext.getResponseDataMap().put(FOCUS_DATA_ID, focus);
- }
- }
- }
-
- /**
- * Template method with old signature, for backward compability.
- */
- protected void setupReRender() {
- }
-
- /**
- * Template methods for fill set of resions to render in subclasses.
- *
- * @param facesContext
- * TODO
- */
- protected void setupReRender(FacesContext facesContext) {
- AjaxContext.getCurrentInstance(facesContext).addRegionsFromComponent(
- this);
- setupReRender();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
- */
- public void queueEvent(FacesEvent event) {
- if (event instanceof ActionEvent && event.getComponent() == this) {
- if (isImmediate()) {
- event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
- } else if (isBypassUpdates()) {
- event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
- } else {
- event.setPhaseId(PhaseId.INVOKE_APPLICATION);
- }
- getParent().queueEvent(event);
- } else {
- super.queueEvent(event);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxSource#addAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
- */
- public void addAjaxListener(AjaxListener listener) {
- addFacesListener(listener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxSource#getAjaxListeners()
- */
- public AjaxListener[] getAjaxListeners() {
- AjaxListener al[] = (AjaxListener[]) getFacesListeners(AjaxListener.class);
- return (al);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxSource#removeAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
- */
- public void removeAjaxListener(AjaxListener listener) {
- removeFacesListener(listener);
-
- }
-
-}
Copied:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
(from rev 164,
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java)
===================================================================
---
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,155 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:21 $
+ *
+ */
+public abstract class AjaxActionComponent extends UICommand implements
+ AjaxComponent, AjaxSource {
+
+ public static final String FOCUS_DATA_ID = "_A4J.AJAX.focus";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ // Hack - throw exception to AjaxViewRoot, to fix state of all iterable components.
+ if (event instanceof AjaxSingleEvent) {
+ throw new AjaxSingleException(getSingleComponent());
+ }
+ // perform default
+ super.broadcast(event);
+ if (event instanceof AjaxEvent) {
+ FacesContext context = getFacesContext();
+ // complete re-Render fields. AjaxEvent deliver before render
+ // response.
+ setupReRender(context);
+ // Put data for send in response
+ Object data = getData();
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ if (null != data) {
+ ajaxContext.setResponseData(data);
+ }
+ String focus = getFocus();
+ if (null != focus) {
+ // search for component in tree.
+ // TODO - use more pourful search, as in h:outputLabel component.
+ UIComponent focusComponent = findComponent(focus);
+ if(null != focusComponent){
+ focus = focusComponent.getClientId(context);
+ }
+ ajaxContext.getResponseDataMap().put(FOCUS_DATA_ID, focus);
+ }
+ }
+ }
+
+ /**
+ * Template method with old signature, for backward compability.
+ */
+ protected void setupReRender() {
+ }
+
+ /**
+ * Template methods for fill set of resions to render in subclasses.
+ *
+ * @param facesContext
+ * TODO
+ */
+ protected void setupReRender(FacesContext facesContext) {
+ AjaxContext.getCurrentInstance(facesContext).addRegionsFromComponent(
+ this);
+ setupReRender();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
+ */
+ public void queueEvent(FacesEvent event) {
+ if (event instanceof ActionEvent && event.getComponent() == this) {
+ if (isImmediate()) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else if (isBypassUpdates()) {
+ event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ getParent().queueEvent(event);
+ if(isAjaxSingle()){
+ super.queueEvent(new AjaxSingleEvent(this));
+ }
+ } else {
+ super.queueEvent(event);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxSource#addAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
+ */
+ public void addAjaxListener(AjaxListener listener) {
+ addFacesListener(listener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxSource#getAjaxListeners()
+ */
+ public AjaxListener[] getAjaxListeners() {
+ AjaxListener al[] = (AjaxListener[]) getFacesListeners(AjaxListener.class);
+ return (al);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxSource#removeAjaxListener(org.ajax4jsf.framework.ajax.AjaxListener)
+ */
+ public void removeAjaxListener(AjaxListener listener) {
+ removeFacesListener(listener);
+
+ }
+
+ protected UIComponent getSingleComponent(){
+ return this;
+ }
+
+}
Deleted:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java 2007-05-02
17:40:09 UTC (rev 158)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -1,809 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.StateManager;
-import javax.faces.application.ViewHandler;
-import javax.faces.application.StateManager.SerializedView;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.el.VariableResolver;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.PhaseId;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-import javax.faces.render.Renderer;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
-import org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.HeaderResourceProducer;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.skin.Skin;
-import org.ajax4jsf.framework.skin.SkinFactory;
-import org.ajax4jsf.framework.skin.SkinNotFoundException;
-import org.ajax4jsf.framework.util.config.WebXml;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * This class incapsulated
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.7 $ $Date: 2007/02/08 19:07:16 $
- *
- */
-public class AjaxContext {
- /**
- * Key for keep request state information in request-scope attributes.
- */
- public static final String AJAX_CONTEXT_KEY = "ajaxContext";
-
- public static final String SCRIPTS_PARAMETER =
"org.ajax4jsf.framework.HEADER_SCRIPTS";
-
- public static final String STYLES_PARAMETER =
"org.ajax4jsf.framework.HEADER_STYLES";
-
- public static final String RESOURCES_PROCESSED =
"org.ajax4jsf.framework.HEADER_PROCESSED";
-
- public static final String RESPONSE_DATA_KEY = "_ajax:data";
-
- private static final Log log = LogFactory.getLog(AjaxContext.class);
-
- private static ComponentInvoker invoker;
-
- private static Map contextClasses = new HashMap();
-
- Set ajaxAreasToRender = new HashSet();
-
- Set ajaxRenderedAreas = new HashSet();
-
- boolean ajaxRequest = false;
-
- boolean ajaxRequestSet = false;
-
- boolean selfRender = false;
-
- Integer viewSequence = new Integer(1);
-
- String submittedRegionClientId = null;
-
- boolean submittedRegionSet = false;
-
- ViewIdHolder viewIdHolder = null;
-
- Map responseDataMap = new HashMap();
-
- Map commonAjaxParameters = new HashMap();
-
- static {
- try {
- // Attempt to create JSF1.2 specific invoker.
- invoker = new JsfOneOneInvoker();
- } catch (Exception e) {
- invoker = new JsfOneOneInvoker();
- }
- }
-
- /**
- * Get instance of current AJAX Context. Instance get by
- * {@link VariableResolver#resolveVariable(FacesContext, String)} for
- * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
- *
- * @return memento instance for current request
- */
- public static AjaxContext getCurrentInstance() {
- FacesContext context = FacesContext.getCurrentInstance();
- return getCurrentInstance(context);
- }
-
- /**
- * Get instance of current AJAX Context. Instance get by
- * {@link VariableResolver#resolveVariable(FacesContext, String)} for
- * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
- *
- * @param context
- * current FacesContext
- * @return instance of AjaxContext.
- */
- public static AjaxContext getCurrentInstance(FacesContext context) {
- if (null == context) {
- throw new NullPointerException("FacesContext is null");
- }
- AjaxContext ajaxContext = (AjaxContext) context.getApplication()
- .getVariableResolver().resolveVariable(context,
- AJAX_CONTEXT_KEY);
- if (null == ajaxContext) {
- // Create default implementation.
- ajaxContext = new AjaxContext();
- context.getExternalContext().getRequestMap().put(AJAX_CONTEXT_KEY,
- ajaxContext);
- }
- return ajaxContext;
- }
-
- /**
- * @param root
- * @param context
- * @param callback
- * @param regionId
- * @return
- * @see
org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnComponent(javax.faces.component.UIComponent,
- * javax.faces.context.FacesContext,
- * org.ajax4jsf.framework.ajax.InvokerCallback, java.lang.String)
- */
- public static boolean invokeOnComponent(UIComponent root,
- FacesContext context, InvokerCallback callback, String regionId) {
- return invoker.invokeOnComponent(root, context, callback, regionId);
- }
-
- /**
- * @param viewRoot
- * @param context
- * @param callback
- * @param phase
- * @see
org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnRegionOrRoot(org.ajax4jsf.framework.ajax.AjaxViewRoot,
- * javax.faces.context.FacesContext,
- * org.ajax4jsf.framework.ajax.InvokerCallback,
- * javax.faces.event.PhaseId)
- */
- public static void invokeOnRegionOrRoot(AjaxViewRoot viewRoot,
- FacesContext context, InvokerCallback callback, PhaseId phase) {
- invoker.invokeOnRegionOrRoot(viewRoot, context, callback, phase);
- }
-
- private InvokerCallback _ajaxInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- if (component instanceof AjaxContainer) {
- AjaxContainer ajax = (AjaxContainer) component;
- renderAjaxRegion(context, component, true);
- } else {
- // Container not found, use Root for encode.
- renderAjaxRegion(context, context.getViewRoot(), true);
- }
- }
-
- public void invokeRoot(FacesContext context) {
- renderAjaxRegion(context, context.getViewRoot(), true);
- }
-
- };
-
- public void renderSubmittedAjaxRegion(FacesContext context) {
- renderSubmittedAjaxRegion(context, true);
- }
-
- public void renderSubmittedAjaxRegion(FacesContext context,
- final boolean useFilterWriter) {
- InvokerCallback ajaxInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- if (component instanceof AjaxContainer) {
- renderAjaxRegion(context, component, useFilterWriter);
- } else {
- // Container not found, use Root for encode.
- renderAjaxRegion(context, context.getViewRoot(),
- useFilterWriter);
- }
- }
-
- public void invokeRoot(FacesContext context) {
- renderAjaxRegion(context, context.getViewRoot(),
- useFilterWriter);
- }
-
- };
- if (!invokeOnComponent(context.getViewRoot(), context, ajaxInvoker,
- getSubmittedRegionClientId(context))) {
- renderAjaxRegion(context, context.getViewRoot(), useFilterWriter);
- }
-
- }
-
- /**
- * @param context
- * @param useFilterWriter
- * TODO
- * @throws AbortProcessingException
- */
- public void renderAjaxRegion(FacesContext context, UIComponent component,
- boolean useFilterWriter) throws FacesException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.RENDER_AJAX_REQUEST,
- component.getId()));
- }
- try {
- setSelfRender(true);
- // create response writer.
- ExternalContext extContext = context.getExternalContext();
- RenderKit renderKit = context.getRenderKit();
- String encoding;
- // Depends if we talk about servlets, portlets, ...
- if (extContext.getRequest() instanceof ServletRequest) {
- ServletRequest request = (ServletRequest) extContext
- .getRequest();
- ServletResponse response = (ServletResponse) extContext
- .getResponse();
- // HACK - bypass MyFaces ( and other ) extensions filter.
-
- // Setup encoding and content type
- String contentType = "text/xml";
- // get the encoding - must be setup by faces context or filter.
- encoding = request.getCharacterEncoding();
- if (encoding == null) {
- encoding = "UTF-8";
- }
- response.setContentType(contentType + ";charset=" + encoding);
- } else
- encoding = "UTF-8";
-
- PrintWriter servletWriter;
- if (useFilterWriter
- && extContext.getRequestMap().containsKey(
- BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
- // HACK - Special case for MyFaces, since <f:view don't call
- // encode methods,
- // encode response as for self-rendered region directly to
- // filter response wrpper.
- // to avoid exceptions, inform wrapper to ignore illegal states
- // for getWriter/Stream.
- ServletResponse servletResponse = (ServletResponse) extContext
- .getRequestMap().get(
- BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE);
- servletResponse.resetBuffer();
- servletWriter = servletResponse.getWriter();
- ((FilterServletResponseWrapper) servletResponse)
- .setUseNullStream(true);
- } else {
- servletWriter = getWriter(extContext);
- }
- ResponseWriter writer = renderKit.createResponseWriter(
- servletWriter, null, encoding);
- context.setResponseWriter(writer);
- // make response
- writer.startDocument();
- encodeAjaxBegin(context, component);
- component.encodeBegin(context);
- ((AjaxContainer) component).encodeAjax(context);
- component.encodeEnd(context);
- saveViewState(context);
- encodeAjaxEnd(context, component);
- writer.endDocument();
- writer.flush();
- writer.close();
- servletWriter.close();
- // Save tree state.
- } catch (IOException e) {
- throw new FacesException(Messages.getMessage(
- Messages.RENDERING_AJAX_REGION_ERROR, component
- .getClientId(context)), e);
- } finally {
- context.responseComplete();
- // component.setRendererType(defaultRenderer);
- }
- }
-
- /**
- * Encode declaration for AJAX response. Render
<html><body>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeAjaxBegin(FacesContext context, UIComponent component)
- throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
- out.startElement(HTML.HTML_ELEMENT, component);
- // TODO - html attributes. lang - from current locale ?
- Locale locale = context.getViewRoot().getLocale();
- out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
- out.startElement(HTML.BODY_ELEMENT, component);
- }
-
- /**
- * End encoding of AJAX response. Render tag with included areas and
- * close </body></html>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeAjaxEnd(FacesContext context, UIComponent component)
- throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
- out.endElement(HTML.BODY_ELEMENT);
- out.endElement(HTML.HTML_ELEMENT);
- }
-
- /**
- * @param context
- * @param root
- * @throws FacesException
- */
- public void processHeadResources(FacesContext context)
- throws FacesException {
- ExternalContext externalContext = context.getExternalContext();
- Map requestMap = externalContext.getRequestMap();
- if (!Boolean.TRUE.equals(requestMap.get(RESOURCES_PROCESSED))) {
- if (null != requestMap.get(BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
- if (log.isDebugEnabled()) {
- log
- .debug("Process component tree for collect used scripts and styles");
- }
- UIViewRoot root = context.getViewRoot();
- Set scripts = new LinkedHashSet();
- Set styles = new LinkedHashSet();
- RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
- .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- RenderKit renderKit = rkFactory.getRenderKit(context, context
- .getViewRoot().getRenderKitId());
- processHeadResources(context, root, scripts, styles, renderKit);
- if (scripts.size() > 0) {
- if (log.isDebugEnabled()) {
- StringBuffer buff = new StringBuffer(
- "Scripts for insert into head : \n");
- for (Iterator iter = scripts.iterator(); iter.hasNext();) {
- String script = (String) iter.next();
- buff.append(script).append("\n");
- }
- log.debug(buff.toString());
- }
- requestMap.put(SCRIPTS_PARAMETER, scripts);
- }
- // Set default style sheet for current skin.
- String styleSheetUri = null;
- try {
- styleSheetUri = (String) SkinFactory.getInstance().getSkin(
- context).getParameter(context,
- Skin.generalStyleSheet);
- } catch (SkinNotFoundException e) {
- log.warn("Current Skin is not found", e);
- }
- if (null != styleSheetUri) {
- String resourceURL = context.getApplication()
- .getViewHandler().getResourceURL(context,
- styleSheetUri);
- // TODO - some resources can be non-session aware, we
- // must
- // skip encoding for this case ?
- // But, in common case - static links not need session
- // info,
- // and dynamic resources perform encodings if nessesary
- // resourceURL =
- // context.getExternalContext().encodeResourceURL(resourceURL);
- styles.add(resourceURL);
- }
- if (styles.size() > 0) {
- if (log.isDebugEnabled()) {
- StringBuffer buff = new StringBuffer(
- "Styles for insert into head : \n");
- for (Iterator iter = styles.iterator(); iter.hasNext();) {
- String style = (String) iter.next();
- buff.append(style).append("\n");
- }
- log.debug(buff.toString());
- }
- requestMap.put(STYLES_PARAMETER, styles);
- }
- // Mark as processed.
- requestMap.put(RESOURCES_PROCESSED, Boolean.TRUE);
- }
-
- }
- }
-
- /**
- * Append nessesary scripts and styles from component ( if renderer
- * implements {@link HeaderResourceProducer}) and recursive process all
- * facets and childrens.
- *
- * @param context
- * TODO
- * @param root
- * @param scripts
- * @param styles
- * @param renderKit
- * TODO
- */
- private void processHeadResources(FacesContext context, UIComponent root,
- Set scripts, Set styles, RenderKit renderKit) {
- Renderer renderer = getRenderer(context, root, renderKit);
- if (null != renderer) {
- if (renderer instanceof HeaderResourceProducer) {
- HeaderResourceProducer producer = (HeaderResourceProducer) renderer;
- Set set = producer.getHeaderScripts(context, root);
- if (null != set) {
- scripts.addAll(set);
- }
- set = producer.getHeaderStyles(context, root);
- if (null != set) {
- styles.addAll(set);
- }
- }
- }
- for (Iterator iter = root.getFacets().values().iterator(); iter
- .hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- processHeadResources(context, child, scripts, styles, renderKit);
- }
- for (Iterator iter = root.getChildren().iterator(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- processHeadResources(context, child, scripts, styles, renderKit);
- }
- }
-
- /**
- * Find renderer for given component.
- *
- * @param context
- * @param comp
- * @param renderKit
- * @return
- */
- private Renderer getRenderer(FacesContext context, UIComponent comp,
- RenderKit renderKit) {
-
- String rendererType = comp.getRendererType();
- if (rendererType != null) {
- return (renderKit.getRenderer(comp.getFamily(), rendererType));
- } else {
- return (null);
- }
-
- }
-
- public void saveViewState(FacesContext context) throws IOException {
- // TODO - for facelets environment, we need to remove transient
- // components.
- try {
- Application.class.getMethod("getExpressionFactory", null);
- } catch (NoSuchMethodException e) {
- // JSF 1.1 !
- }
- ResponseWriter writer = context.getResponseWriter();
- StateManager stateManager = context.getApplication().getStateManager();
- SerializedView serializedView = stateManager
- .saveSerializedView(context);
- if (null != serializedView) {
- StringWriter bufWriter = new StringWriter();
- ResponseWriter cloneWithWriter = writer.cloneWithWriter(bufWriter);
- context.setResponseWriter(cloneWithWriter);
- stateManager.writeState(context, serializedView);
- cloneWithWriter.flush();
- if (bufWriter.getBuffer().length() > 0) {
- context.getExternalContext().getRequestMap().put(
- AjaxViewHandler.SERIALIZED_STATE_KEY,
- bufWriter.toString());
- }
- // Restore original writer.
- context.setResponseWriter(writer);
- }
- }
-
- /**
- * @return Returns the ajaxRequest.
- */
- public boolean isAjaxRequest() {
- return isAjaxRequest(FacesContext.getCurrentInstance());
- }
-
- /**
- * @return Returns the ajaxRequest.
- */
- public boolean isAjaxRequest(FacesContext context) {
- if (!this.ajaxRequestSet) {
- ajaxRequest = null != getSubmittedRegionClientId(context);
- ajaxRequestSet = true;
- }
- return ajaxRequest;
- }
-
- /**
- * @param ajaxRequest
- * The ajaxRequest to set.
- */
- public void setAjaxRequest(boolean ajaxRequest) {
- this.ajaxRequest = ajaxRequest;
- this.ajaxRequestSet = true;
- }
-
- /**
- * @return Returns the ajaxAreasToRender.
- */
- public Set getAjaxAreasToRender() {
- return this.ajaxAreasToRender;
- }
-
- /**
- * Add affected regions's ID to ajaxView component.
- *
- * @param component
- */
- public void addRegionsFromComponent(UIComponent component) {
- // First step - find parent ajax view
- Set ajaxRegions = AjaxRendererUtils.getAjaxAreas(component);
- // if (ajaxRegions == null){
- // FacesContext context = FacesContext.getCurrentInstance();
- // ajaxRegions = AjaxRendererUtils.getAbsoluteId(context,component);
- // }
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.INVOKE_AJAX_REGION_LISTENER,
- component.getId()));
- }
- if (ajaxRegions != null) {
- for (Iterator iter = ajaxRegions.iterator(); iter.hasNext();) {
- String id = iter.next().toString();
- ajaxAreasToRender.add(convertId(component, id));
- }
- }
- }
-
- public void addComponentToAjaxRender(UIComponent component) {
- this.ajaxAreasToRender.add(AjaxRendererUtils.getAbsoluteId(component));
- }
-
- public void addComponentToAjaxRender(UIComponent base, String id) {
- this.ajaxAreasToRender.add(convertId(base, id));
- }
-
- /**
- * Test for relative id of target components. Attempt convert to
- * absolute. For use as argument for
- * {@link UIComponent#findComponent(java.lang.String)}
- *
- * @param component
- * @param id
- * @return
- */
- private String convertId(UIComponent component, String id) {
- if (id.charAt(0) == NamingContainer.SEPARATOR_CHAR) {
- return id;
- }
- if (null == component) {
- throw new NullPointerException(
- "Base component for search re-rendered compnnent is null");
- }
- UIComponent target = null;
- UIComponent parent = component;
- UIComponent root = component;
- while (null == target && null != parent) {
- target = parent.findComponent(id);
- root = parent;
- parent = parent.getParent();
- }
- if (null == target) {
- target = findUIComponentBelow(root, id);
- }
- if (null != target) {
- return AjaxRendererUtils.getAbsoluteId(target);
- }
- log.warn("Target component for id "+id+" not found");
- return id;
- }
-
- private UIComponent findUIComponentBelow(UIComponent root,
- String id) {
-
- UIComponent target = null;
- for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- if (child instanceof NamingContainer) {
- try {
- target = child.findComponent(id);
- } catch (IllegalArgumentException iae) {
- continue;
- }
- }
- if (target == null) {
- if (child.getChildCount() > 0) {
- target = findUIComponentBelow(child, id);
- }
- }
-
- if (target != null) {
- break;
- }
-
- }
- return target;
- }
-
- /**
- * @return Returns the ajaxRenderedAreas.
- */
- public Set getAjaxRenderedAreas() {
- return ajaxRenderedAreas;
- }
-
- public void addRenderedArea(String id) {
- ajaxRenderedAreas.add(id);
- }
-
- public boolean removeRenderedArea(String id) {
- return ajaxRenderedAreas.remove(id);
- }
-
- /**
- * @return Returns the submittedClientId.
- */
- public String getSubmittedRegionClientId(FacesContext context) {
- if (!this.submittedRegionSet) {
- this.submittedRegionClientId = (String) context
- .getExternalContext().getRequestParameterMap().get(
- AjaxContainerRenderer.AJAX_PARAMETER_NAME);
- this.submittedRegionSet = true;
- if (!this.ajaxRequestSet) {
- setAjaxRequest(this.submittedRegionClientId != null);
- }
- }
- return this.submittedRegionClientId;
- }
-
- /**
- * @param submittedClientId
- * The submittedClientId to set.
- */
- public void setSubmittedRegionClientId(String submittedClientId) {
- this.submittedRegionClientId = submittedClientId;
- this.submittedRegionSet = true;
- }
-
- /**
- * @return Returns the selfRender.
- */
- public boolean isSelfRender() {
- return selfRender;
- }
-
- /**
- * @param selfRender
- * The selfRender to set.
- */
- public void setSelfRender(boolean selfRender) {
- this.selfRender = selfRender;
- }
-
- /**
- * @return the vievIdHolder
- */
- public ViewIdHolder getViewIdHolder() {
- return viewIdHolder;
- }
-
- /**
- * @param viewIdHolder
- * the vievIdHolder to set
- */
- public void setViewIdHolder(ViewIdHolder viewIdHolder) {
- this.viewIdHolder = viewIdHolder;
- }
-
- /**
- * @return the responseData
- */
- public Object getResponseData() {
- return responseDataMap.get(RESPONSE_DATA_KEY);
- }
-
- /**
- * @param responseData
- * the responseData to set
- */
- public void setResponseData(Object responseData) {
- this.responseDataMap.put(RESPONSE_DATA_KEY, responseData);
- }
-
- /**
- * @return the responseDataMap
- */
- public Map getResponseDataMap() {
- return responseDataMap;
- }
-
- /**
- * Gives back the writer of a Response object.
- *
- * @param extContext
- * The external context.
- * @return The writer of the response.
- * @throws FacesException
- * If the response object has no getWriter() method.
- */
- protected PrintWriter getWriter(ExternalContext extContext)
- throws FacesException {
- PrintWriter writer = null;
- Object response = extContext.getResponse();
- try {
- Method gW = response.getClass()
- .getMethod("getWriter", new Class[0]);
- writer = (PrintWriter) gW.invoke(response, new Object[0]);
- } catch (Exception e) {
- throw new FacesException(e);
- }
- return writer;
- }
-
- public String getAjaxActionURL() {
- return getAjaxActionURL(FacesContext.getCurrentInstance());
- }
-
- public String getAjaxActionURL(FacesContext context) {
- // Check arguments
- if (null == context) {
- throw new NullPointerException(
- "Faces context for build AJAX Action URL is null");
- }
- UIViewRoot viewRoot = context.getViewRoot();
- if (null == viewRoot) {
- throw new NullPointerException(
- "Faces view tree for build AJAX Action URL is null");
- }
- String viewId = viewRoot.getViewId();
- if (null == viewId) {
- throw new NullPointerException(
- "View id for build AJAX Action URL is null");
- }
- if (!viewId.startsWith("/")) {
- throw new IllegalArgumentException(
- "Illegal view Id for build AJAX Action URL: " + viewId);
- }
- ViewHandler viewHandler = context.getApplication().getViewHandler();
- return context.getExternalContext().encodeActionURL(
- viewHandler.getActionURL(context, viewId));
- }
-
- /**
- * @return the commonAjaxParameters
- */
- public Map getCommonAjaxParameters() {
- return commonAjaxParameters;
- }
-
-}
\ No newline at end of file
Copied:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java (from
rev 164, trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java)
===================================================================
--- tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,806 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.application.StateManager.SerializedView;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.VariableResolver;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.Renderer;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
+import org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper;
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.HeaderResourceProducer;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.skin.Skin;
+import org.ajax4jsf.framework.skin.SkinFactory;
+import org.ajax4jsf.framework.skin.SkinNotFoundException;
+import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This class incapsulated
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.7 $ $Date: 2007/02/08 19:07:16 $
+ *
+ */
+public class AjaxContext {
+ /**
+ * Key for keep request state information in request-scope attributes.
+ */
+ public static final String AJAX_CONTEXT_KEY = "ajaxContext";
+
+ public static final String SCRIPTS_PARAMETER =
"org.ajax4jsf.framework.HEADER_SCRIPTS";
+
+ public static final String STYLES_PARAMETER =
"org.ajax4jsf.framework.HEADER_STYLES";
+
+ public static final String RESOURCES_PROCESSED =
"org.ajax4jsf.framework.HEADER_PROCESSED";
+
+ public static final String RESPONSE_DATA_KEY = "_ajax:data";
+
+ private static final Log log = LogFactory.getLog(AjaxContext.class);
+
+ private static ComponentInvoker invoker;
+
+ private static Map contextClasses = new HashMap();
+
+ Set ajaxAreasToRender = new HashSet();
+
+ Set ajaxRenderedAreas = new HashSet();
+
+ boolean ajaxRequest = false;
+
+ boolean ajaxRequestSet = false;
+
+ boolean selfRender = false;
+
+ Integer viewSequence = new Integer(1);
+
+ String submittedRegionClientId = null;
+
+ boolean submittedRegionSet = false;
+
+ ViewIdHolder viewIdHolder = null;
+
+ Map responseDataMap = new HashMap();
+
+ Map commonAjaxParameters = new HashMap();
+
+ static {
+ try {
+ // Attempt to create JSF1.2 specific invoker.
+ invoker = new JsfOneOneInvoker();
+ } catch (Exception e) {
+ invoker = new JsfOneOneInvoker();
+ }
+ }
+
+ /**
+ * Get instance of current AJAX Context. Instance get by
+ * {@link VariableResolver#resolveVariable(FacesContext, String)} for
+ * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
+ *
+ * @return memento instance for current request
+ */
+ public static AjaxContext getCurrentInstance() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ return getCurrentInstance(context);
+ }
+
+ /**
+ * Get instance of current AJAX Context. Instance get by
+ * {@link VariableResolver#resolveVariable(FacesContext, String)} for
+ * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
+ *
+ * @param context
+ * current FacesContext
+ * @return instance of AjaxContext.
+ */
+ public static AjaxContext getCurrentInstance(FacesContext context) {
+ if (null == context) {
+ throw new NullPointerException("FacesContext is null");
+ }
+ AjaxContext ajaxContext = (AjaxContext) context.getApplication()
+ .getVariableResolver().resolveVariable(context,
+ AJAX_CONTEXT_KEY);
+ if (null == ajaxContext) {
+ // Create default implementation.
+ ajaxContext = new AjaxContext();
+ context.getExternalContext().getRequestMap().put(AJAX_CONTEXT_KEY,
+ ajaxContext);
+ }
+ return ajaxContext;
+ }
+
+ /**
+ * @param root
+ * @param context
+ * @param callback
+ * @param regionId
+ * @return
+ * @see
org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnComponent(javax.faces.component.UIComponent,
+ * javax.faces.context.FacesContext,
+ * org.ajax4jsf.framework.ajax.InvokerCallback, java.lang.String)
+ */
+ public static boolean invokeOnComponent(UIComponent root,
+ FacesContext context, InvokerCallback callback, String regionId) {
+ return invoker.invokeOnComponent(root, context, callback, regionId);
+ }
+
+ /**
+ * @param viewRoot
+ * @param context
+ * @param callback
+ * @see
org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnRegionOrRoot(org.ajax4jsf.framework.ajax.AjaxViewRoot,
+ * javax.faces.context.FacesContext,
+ * org.ajax4jsf.framework.ajax.InvokerCallback)
+ */
+ public static void invokeOnRegionOrRoot(AjaxViewRoot viewRoot,
+ FacesContext context, InvokerCallback callback) {
+ invoker.invokeOnRegionOrRoot(viewRoot, context, callback);
+ }
+
+ private InvokerCallback _ajaxInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ if (component instanceof AjaxContainer) {
+ AjaxContainer ajax = (AjaxContainer) component;
+ renderAjaxRegion(context, component, true);
+ } else {
+ // Container not found, use Root for encode.
+ renderAjaxRegion(context, context.getViewRoot(), true);
+ }
+ }
+
+ public void invokeRoot(FacesContext context) {
+ renderAjaxRegion(context, context.getViewRoot(), true);
+ }
+
+ };
+
+ public void renderSubmittedAjaxRegion(FacesContext context) {
+ renderSubmittedAjaxRegion(context, true);
+ }
+
+ public void renderSubmittedAjaxRegion(FacesContext context,
+ final boolean useFilterWriter) {
+ InvokerCallback ajaxInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ if (component instanceof AjaxContainer) {
+ renderAjaxRegion(context, component, useFilterWriter);
+ } else {
+ // Container not found, use Root for encode.
+ renderAjaxRegion(context, context.getViewRoot(),
+ useFilterWriter);
+ }
+ }
+
+ public void invokeRoot(FacesContext context) {
+ renderAjaxRegion(context, context.getViewRoot(),
+ useFilterWriter);
+ }
+
+ };
+ if (!invokeOnComponent(context.getViewRoot(), context, ajaxInvoker,
+ getSubmittedRegionClientId(context))) {
+ renderAjaxRegion(context, context.getViewRoot(), useFilterWriter);
+ }
+
+ }
+
+ /**
+ * @param context
+ * @param useFilterWriter
+ * TODO
+ * @throws AbortProcessingException
+ */
+ public void renderAjaxRegion(FacesContext context, UIComponent component,
+ boolean useFilterWriter) throws FacesException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.RENDER_AJAX_REQUEST,
+ component.getId()));
+ }
+ try {
+ setSelfRender(true);
+ // create response writer.
+ ExternalContext extContext = context.getExternalContext();
+ RenderKit renderKit = context.getRenderKit();
+ String encoding;
+ // Depends if we talk about servlets, portlets, ...
+ if (extContext.getRequest() instanceof ServletRequest) {
+ ServletRequest request = (ServletRequest) extContext
+ .getRequest();
+ ServletResponse response = (ServletResponse) extContext
+ .getResponse();
+ // HACK - bypass MyFaces ( and other ) extensions filter.
+
+ // Setup encoding and content type
+ String contentType = "text/xml";
+ // get the encoding - must be setup by faces context or filter.
+ encoding = request.getCharacterEncoding();
+ if (encoding == null) {
+ encoding = "UTF-8";
+ }
+ response.setContentType(contentType + ";charset=" + encoding);
+ } else
+ encoding = "UTF-8";
+
+ PrintWriter servletWriter;
+ if (useFilterWriter
+ && extContext.getRequestMap().containsKey(
+ BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
+ // HACK - Special case for MyFaces, since <f:view don't call
+ // encode methods,
+ // encode response as for self-rendered region directly to
+ // filter response wrpper.
+ // to avoid exceptions, inform wrapper to ignore illegal states
+ // for getWriter/Stream.
+ ServletResponse servletResponse = (ServletResponse) extContext
+ .getRequestMap().get(
+ BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE);
+ servletResponse.resetBuffer();
+ servletWriter = servletResponse.getWriter();
+ ((FilterServletResponseWrapper) servletResponse)
+ .setUseNullStream(true);
+ } else {
+ servletWriter = getWriter(extContext);
+ }
+ ResponseWriter writer = renderKit.createResponseWriter(
+ servletWriter, null, encoding);
+ context.setResponseWriter(writer);
+ // make response
+ writer.startDocument();
+ encodeAjaxBegin(context, component);
+ component.encodeBegin(context);
+ ((AjaxContainer) component).encodeAjax(context);
+ component.encodeEnd(context);
+ saveViewState(context);
+ encodeAjaxEnd(context, component);
+ writer.endDocument();
+ writer.flush();
+ writer.close();
+ servletWriter.close();
+ // Save tree state.
+ } catch (IOException e) {
+ throw new FacesException(Messages.getMessage(
+ Messages.RENDERING_AJAX_REGION_ERROR, component
+ .getClientId(context)), e);
+ } finally {
+ context.responseComplete();
+ // component.setRendererType(defaultRenderer);
+ }
+ }
+
+ /**
+ * Encode declaration for AJAX response. Render
<html><body>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeAjaxBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+ out.startElement(HTML.HTML_ELEMENT, component);
+ // TODO - html attributes. lang - from current locale ?
+ Locale locale = context.getViewRoot().getLocale();
+ out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
+ out.startElement(HTML.BODY_ELEMENT, component);
+ }
+
+ /**
+ * End encoding of AJAX response. Render tag with included areas and
+ * close </body></html>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeAjaxEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+ out.endElement(HTML.BODY_ELEMENT);
+ out.endElement(HTML.HTML_ELEMENT);
+ }
+
+ /**
+ * @param context
+ * @param root
+ * @throws FacesException
+ */
+ public void processHeadResources(FacesContext context)
+ throws FacesException {
+ ExternalContext externalContext = context.getExternalContext();
+ Map requestMap = externalContext.getRequestMap();
+ if (!Boolean.TRUE.equals(requestMap.get(RESOURCES_PROCESSED))) {
+ if (null != requestMap.get(BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Process component tree for collect used scripts and styles");
+ }
+ UIViewRoot root = context.getViewRoot();
+ Set scripts = new LinkedHashSet();
+ Set styles = new LinkedHashSet();
+ RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKit renderKit = rkFactory.getRenderKit(context, context
+ .getViewRoot().getRenderKitId());
+ processHeadResources(context, root, scripts, styles, renderKit);
+ if (scripts.size() > 0) {
+ if (log.isDebugEnabled()) {
+ StringBuffer buff = new StringBuffer(
+ "Scripts for insert into head : \n");
+ for (Iterator iter = scripts.iterator(); iter.hasNext();) {
+ String script = (String) iter.next();
+ buff.append(script).append("\n");
+ }
+ log.debug(buff.toString());
+ }
+ requestMap.put(SCRIPTS_PARAMETER, scripts);
+ }
+ // Set default style sheet for current skin.
+ String styleSheetUri = null;
+ try {
+ styleSheetUri = (String) SkinFactory.getInstance().getSkin(
+ context).getParameter(context,
+ Skin.generalStyleSheet);
+ } catch (SkinNotFoundException e) {
+ log.warn("Current Skin is not found", e);
+ }
+ if (null != styleSheetUri) {
+ String resourceURL = context.getApplication()
+ .getViewHandler().getResourceURL(context,
+ styleSheetUri);
+ // TODO - some resources can be non-session aware, we
+ // must
+ // skip encoding for this case ?
+ // But, in common case - static links not need session
+ // info,
+ // and dynamic resources perform encodings if nessesary
+ // resourceURL =
+ // context.getExternalContext().encodeResourceURL(resourceURL);
+ styles.add(resourceURL);
+ }
+ if (styles.size() > 0) {
+ if (log.isDebugEnabled()) {
+ StringBuffer buff = new StringBuffer(
+ "Styles for insert into head : \n");
+ for (Iterator iter = styles.iterator(); iter.hasNext();) {
+ String style = (String) iter.next();
+ buff.append(style).append("\n");
+ }
+ log.debug(buff.toString());
+ }
+ requestMap.put(STYLES_PARAMETER, styles);
+ }
+ // Mark as processed.
+ requestMap.put(RESOURCES_PROCESSED, Boolean.TRUE);
+ }
+
+ }
+ }
+
+ /**
+ * Append nessesary scripts and styles from component ( if renderer
+ * implements {@link HeaderResourceProducer}) and recursive process all
+ * facets and childrens.
+ *
+ * @param context
+ * TODO
+ * @param root
+ * @param scripts
+ * @param styles
+ * @param renderKit
+ * TODO
+ */
+ private void processHeadResources(FacesContext context, UIComponent root,
+ Set scripts, Set styles, RenderKit renderKit) {
+ Renderer renderer = getRenderer(context, root, renderKit);
+ if (null != renderer) {
+ if (renderer instanceof HeaderResourceProducer) {
+ HeaderResourceProducer producer = (HeaderResourceProducer) renderer;
+ Set set = producer.getHeaderScripts(context, root);
+ if (null != set) {
+ scripts.addAll(set);
+ }
+ set = producer.getHeaderStyles(context, root);
+ if (null != set) {
+ styles.addAll(set);
+ }
+ }
+ }
+ for (Iterator iter = root.getFacets().values().iterator(); iter
+ .hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ processHeadResources(context, child, scripts, styles, renderKit);
+ }
+ for (Iterator iter = root.getChildren().iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ processHeadResources(context, child, scripts, styles, renderKit);
+ }
+ }
+
+ /**
+ * Find renderer for given component.
+ *
+ * @param context
+ * @param comp
+ * @param renderKit
+ * @return
+ */
+ private Renderer getRenderer(FacesContext context, UIComponent comp,
+ RenderKit renderKit) {
+
+ String rendererType = comp.getRendererType();
+ if (rendererType != null) {
+ return (renderKit.getRenderer(comp.getFamily(), rendererType));
+ } else {
+ return (null);
+ }
+
+ }
+
+ public void saveViewState(FacesContext context) throws IOException {
+ // TODO - for facelets environment, we need to remove transient
+ // components.
+ try {
+ Application.class.getMethod("getExpressionFactory", null);
+ } catch (NoSuchMethodException e) {
+ // JSF 1.1 !
+ }
+ ResponseWriter writer = context.getResponseWriter();
+ StateManager stateManager = context.getApplication().getStateManager();
+ SerializedView serializedView = stateManager
+ .saveSerializedView(context);
+ if (null != serializedView) {
+ StringWriter bufWriter = new StringWriter();
+ ResponseWriter cloneWithWriter = writer.cloneWithWriter(bufWriter);
+ context.setResponseWriter(cloneWithWriter);
+ stateManager.writeState(context, serializedView);
+ cloneWithWriter.flush();
+ if (bufWriter.getBuffer().length() > 0) {
+ context.getExternalContext().getRequestMap().put(
+ AjaxViewHandler.SERIALIZED_STATE_KEY,
+ bufWriter.toString());
+ }
+ // Restore original writer.
+ context.setResponseWriter(writer);
+ }
+ }
+
+ /**
+ * @return Returns the ajaxRequest.
+ */
+ public boolean isAjaxRequest() {
+ return isAjaxRequest(FacesContext.getCurrentInstance());
+ }
+
+ /**
+ * @return Returns the ajaxRequest.
+ */
+ public boolean isAjaxRequest(FacesContext context) {
+ if (!this.ajaxRequestSet) {
+ ajaxRequest = null != getSubmittedRegionClientId(context);
+ ajaxRequestSet = true;
+ }
+ return ajaxRequest;
+ }
+
+ /**
+ * @param ajaxRequest
+ * The ajaxRequest to set.
+ */
+ public void setAjaxRequest(boolean ajaxRequest) {
+ this.ajaxRequest = ajaxRequest;
+ this.ajaxRequestSet = true;
+ }
+
+ /**
+ * @return Returns the ajaxAreasToRender.
+ */
+ public Set getAjaxAreasToRender() {
+ return this.ajaxAreasToRender;
+ }
+
+ /**
+ * Add affected regions's ID to ajaxView component.
+ *
+ * @param component
+ */
+ public void addRegionsFromComponent(UIComponent component) {
+ // First step - find parent ajax view
+ Set ajaxRegions = AjaxRendererUtils.getAjaxAreas(component);
+ // if (ajaxRegions == null){
+ // FacesContext context = FacesContext.getCurrentInstance();
+ // ajaxRegions = AjaxRendererUtils.getAbsoluteId(context,component);
+ // }
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.INVOKE_AJAX_REGION_LISTENER,
+ component.getId()));
+ }
+ if (ajaxRegions != null) {
+ for (Iterator iter = ajaxRegions.iterator(); iter.hasNext();) {
+ String id = iter.next().toString();
+ ajaxAreasToRender.add(convertId(component, id));
+ }
+ }
+ }
+
+ public void addComponentToAjaxRender(UIComponent component) {
+ this.ajaxAreasToRender.add(AjaxRendererUtils.getAbsoluteId(component));
+ }
+
+ public void addComponentToAjaxRender(UIComponent base, String id) {
+ this.ajaxAreasToRender.add(convertId(base, id));
+ }
+
+ /**
+ * Test for relative id of target components. Attempt convert to
+ * absolute. For use as argument for
+ * {@link UIComponent#findComponent(java.lang.String)}
+ *
+ * @param component
+ * @param id
+ * @return
+ */
+ private String convertId(UIComponent component, String id) {
+ if (id.charAt(0) == NamingContainer.SEPARATOR_CHAR) {
+ return id;
+ }
+ if (null == component) {
+ throw new NullPointerException(
+ "Base component for search re-rendered compnnent is null");
+ }
+ UIComponent target = null;
+ UIComponent parent = component;
+ UIComponent root = component;
+ while (null == target && null != parent) {
+ target = parent.findComponent(id);
+ root = parent;
+ parent = parent.getParent();
+ }
+ if (null == target) {
+ target = findUIComponentBelow(root, id);
+ }
+ if (null != target) {
+ return AjaxRendererUtils.getAbsoluteId(target);
+ }
+ log.warn("Target component for id "+id+" not found");
+ return id;
+ }
+
+ private UIComponent findUIComponentBelow(UIComponent root,
+ String id) {
+
+ UIComponent target = null;
+ for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if (child instanceof NamingContainer) {
+ try {
+ target = child.findComponent(id);
+ } catch (IllegalArgumentException iae) {
+ continue;
+ }
+ }
+ if (target == null) {
+ if (child.getChildCount() > 0) {
+ target = findUIComponentBelow(child, id);
+ }
+ }
+
+ if (target != null) {
+ break;
+ }
+
+ }
+ return target;
+ }
+
+ /**
+ * @return Returns the ajaxRenderedAreas.
+ */
+ public Set getAjaxRenderedAreas() {
+ return ajaxRenderedAreas;
+ }
+
+ public void addRenderedArea(String id) {
+ ajaxRenderedAreas.add(id);
+ }
+
+ public boolean removeRenderedArea(String id) {
+ return ajaxRenderedAreas.remove(id);
+ }
+
+ /**
+ * @return Returns the submittedClientId.
+ */
+ public String getSubmittedRegionClientId(FacesContext context) {
+ if (!this.submittedRegionSet) {
+ this.submittedRegionClientId = (String) context
+ .getExternalContext().getRequestParameterMap().get(
+ AjaxContainerRenderer.AJAX_PARAMETER_NAME);
+ this.submittedRegionSet = true;
+ if (!this.ajaxRequestSet) {
+ setAjaxRequest(this.submittedRegionClientId != null);
+ }
+ }
+ return this.submittedRegionClientId;
+ }
+
+ /**
+ * @param submittedClientId
+ * The submittedClientId to set.
+ */
+ public void setSubmittedRegionClientId(String submittedClientId) {
+ this.submittedRegionClientId = submittedClientId;
+ this.submittedRegionSet = true;
+ }
+
+ /**
+ * @return Returns the selfRender.
+ */
+ public boolean isSelfRender() {
+ return selfRender;
+ }
+
+ /**
+ * @param selfRender
+ * The selfRender to set.
+ */
+ public void setSelfRender(boolean selfRender) {
+ this.selfRender = selfRender;
+ }
+
+ /**
+ * @return the vievIdHolder
+ */
+ public ViewIdHolder getViewIdHolder() {
+ return viewIdHolder;
+ }
+
+ /**
+ * @param viewIdHolder
+ * the vievIdHolder to set
+ */
+ public void setViewIdHolder(ViewIdHolder viewIdHolder) {
+ this.viewIdHolder = viewIdHolder;
+ }
+
+ /**
+ * @return the responseData
+ */
+ public Object getResponseData() {
+ return responseDataMap.get(RESPONSE_DATA_KEY);
+ }
+
+ /**
+ * @param responseData
+ * the responseData to set
+ */
+ public void setResponseData(Object responseData) {
+ this.responseDataMap.put(RESPONSE_DATA_KEY, responseData);
+ }
+
+ /**
+ * @return the responseDataMap
+ */
+ public Map getResponseDataMap() {
+ return responseDataMap;
+ }
+
+ /**
+ * Gives back the writer of a Response object.
+ *
+ * @param extContext
+ * The external context.
+ * @return The writer of the response.
+ * @throws FacesException
+ * If the response object has no getWriter() method.
+ */
+ protected PrintWriter getWriter(ExternalContext extContext)
+ throws FacesException {
+ PrintWriter writer = null;
+ Object response = extContext.getResponse();
+ try {
+ Method gW = response.getClass()
+ .getMethod("getWriter", new Class[0]);
+ writer = (PrintWriter) gW.invoke(response, new Object[0]);
+ } catch (Exception e) {
+ throw new FacesException(e);
+ }
+ return writer;
+ }
+
+ public String getAjaxActionURL() {
+ return getAjaxActionURL(FacesContext.getCurrentInstance());
+ }
+
+ public String getAjaxActionURL(FacesContext context) {
+ // Check arguments
+ if (null == context) {
+ throw new NullPointerException(
+ "Faces context for build AJAX Action URL is null");
+ }
+ UIViewRoot viewRoot = context.getViewRoot();
+ if (null == viewRoot) {
+ throw new NullPointerException(
+ "Faces view tree for build AJAX Action URL is null");
+ }
+ String viewId = viewRoot.getViewId();
+ if (null == viewId) {
+ throw new NullPointerException(
+ "View id for build AJAX Action URL is null");
+ }
+ if (!viewId.startsWith("/")) {
+ throw new IllegalArgumentException(
+ "Illegal view Id for build AJAX Action URL: " + viewId);
+ }
+ ViewHandler viewHandler = context.getApplication().getViewHandler();
+ return context.getExternalContext().encodeActionURL(
+ viewHandler.getActionURL(context, viewId));
+ }
+
+ /**
+ * @return the commonAjaxParameters
+ */
+ public Map getCommonAjaxParameters() {
+ return commonAjaxParameters;
+ }
+
+}
\ No newline at end of file
Copied:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java
(from rev 164,
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java)
===================================================================
---
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,40 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.faces.event.PhaseId;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class AjaxSingleEvent extends FacesEvent {
+
+ /**
+ * @param arg0
+ */
+ public AjaxSingleEvent(UIComponent arg0) {
+ super(arg0);
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener arg0) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener arg0) {
+ }
+
+ public PhaseId getPhaseId() {
+ return PhaseId.APPLY_REQUEST_VALUES;
+ }
+}
Copied:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java
(from rev 164,
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java)
===================================================================
---
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,31 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class AjaxSingleException extends RuntimeException {
+
+ private UIComponent component;
+
+ /**
+ * @param component
+ */
+ public AjaxSingleException(UIComponent componemt) {
+// super();
+ this.component = componemt;
+ }
+
+ /**
+ * @return the component
+ */
+ public UIComponent getComponent() {
+ return component;
+ }
+
+}
Deleted:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java 2007-05-02
17:40:09 UTC (rev 158)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -1,549 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.io.IOException;
-
-import javax.faces.FacesException;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
-
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.collections.Buffer;
-import org.apache.commons.collections.BufferUnderflowException;
-import org.apache.commons.collections.UnboundedFifoBuffer;
-
-/**
- * Custom ViewRoot for support render parts of tree for Ajax requests. Main
- * difference from default ViewRoot - store events queue and unique id counter
- * in request-scope variables. In common realisation, store request-scope
- * variables in component produce errors in case of concurrent requests to same
- * view.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.4 $ $Date: 2007/02/28 17:01:01 $
- *
- */
-public class AjaxViewRoot extends UIViewRoot implements AjaxContainer {
-
- public static final String ROOT_ID = "_viewRoot";
-
- private AjaxRegionBrige _brige;
-
-
- /**
- *
- */
- public AjaxViewRoot() {
- super();
- super.setId(ROOT_ID);
- _brige = new AjaxRegionBrige(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#getId()
- */
- // public String getId() {
- // return ROOT_ID;
- // }
- public String getRendererType() {
- return (COMPONENT_FAMILY);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#broadcast(javax.faces.event.FacesEvent)
- */
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- super.broadcast(event);
- getBrige().broadcast(event);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#getAjaxListener()
- */
- public MethodBinding getAjaxListener() {
- return getBrige().getAjaxListener();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isImmediate()
- */
- public boolean isImmediate() {
- return getBrige().isImmediate();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSubmitted()
- */
- public boolean isSubmitted() {
- return getBrige().isSubmitted();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponent#queueEvent(javax.faces.event.FacesEvent)
- */
- public void queueEvent(FacesEvent event) {
- if (event == null)
- throw new NullPointerException(Messages
- .getMessage(Messages.NULL_EVENT_SUBMITTED_ERROR));
- if (event.getPhaseId().compareTo(PhaseId.RENDER_RESPONSE) == 0) {
- // HACK - Special case - Ajax Events to RenderResponse phase queue.
- // in future, with JSF 1.2 it must be done by invokeOnComponent
- // method.
- // In 1.1 , events to RENDER_RESPONSE phase not used.
- getAjaxEventsQueue(getFacesContext()).add(event);
- } else {
- getEventsQueue(getFacesContext(), event.getPhaseId()).add(event);
- }
- }
-
- /**
- * Broadcast events for specified Phase
- *
- * @param context
- * @param phaseId -
- * phase, for wich events must be processed.
- */
- void broadcastEvents(FacesContext context, PhaseId phaseId) {
- Buffer[] events = getEvents(context);
- Buffer anyPhaseEvents = events[PhaseId.ANY_PHASE.getOrdinal()];
- Buffer phaseEvents = events[phaseId.getOrdinal()];
- if (phaseEvents.isEmpty() && anyPhaseEvents.isEmpty())
- return;
- // FacesEvent event = null;
- boolean haveAnyPhaseEvents = !anyPhaseEvents.isEmpty();
- boolean havePhaseEvents = !phaseEvents.isEmpty();
- do {
- // ANY_PHASE first
- processEvents(anyPhaseEvents, haveAnyPhaseEvents);
-
- processEvents(phaseEvents, havePhaseEvents);
- // Events can queued in other events processing
- haveAnyPhaseEvents = !anyPhaseEvents.isEmpty();
- havePhaseEvents = !phaseEvents.isEmpty();
- } while (haveAnyPhaseEvents || havePhaseEvents);
- if (context.getRenderResponse() || context.getResponseComplete()) {
- clearEvents(context);
- }
-
- }
-
- /**
- * @param phaseEventsQueue
- * @param havePhaseEvents
- */
- public void processEvents(Buffer phaseEventsQueue, boolean havePhaseEvents) {
- FacesEvent event;
- while (havePhaseEvents) {
- try {
- event = (FacesEvent) phaseEventsQueue.remove();
- UIComponent source = event.getComponent();
- try {
- source.broadcast(event);
- } catch (AbortProcessingException e) {
- // abort event processing
- // Page 3-30 of JSF 1.1 spec: "Throw an
- // AbortProcessingException, to tell the JSF implementation
- // that no further broadcast of this event, or any further
- // events, should take place."
- // clearEvents();
- // return;
- }
- } catch (BufferUnderflowException e) {
- havePhaseEvents = false;
- }
- }
- }
-
- public void broadcastAjaxEvents(FacesContext context) {
- Buffer queue = getAjaxEventsQueue(context);
- processEvents(queue, !queue.isEmpty());
- }
-
- private Buffer[] events;
-
- private Buffer ajaxEvents = new UnboundedFifoBuffer();
-
- /**
- * Use FIFO buffers for hold Faces Events. Hold this buffers in Request
- * scope parameters for support any concurrent requests for same component
- * tree ( since RI hold component tree in session ).
- *
- * @param context
- * @param phase
- * @return
- */
- protected Buffer getEventsQueue(FacesContext context, PhaseId phase) {
- return getEvents(context)[phase.getOrdinal()];
- }
-
- /**
- * @return
- */
- protected Buffer[] getEvents(FacesContext context) {
- if (events == null) {
- clearEvents(context);
- }
- return events;
- }
-
- /**
- * Special Fifo Buffer for ajax events to Render Responce phase.
- *
- * @param context
- * @return
- */
- protected Buffer getAjaxEventsQueue(FacesContext context) {
-
- return ajaxEvents;
- }
-
- public void clearEvents(FacesContext context) {
- int len;
- events = new Buffer[len = PhaseId.VALUES.size()];
- for (int i = 0; i < len; i++) {
- events[i] = new UnboundedFifoBuffer();
- }
- }
-
- private InvokerCallback _decodeInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- component.processDecodes(context);
- }
-
- public void invokeRoot(FacesContext context) {
- AjaxViewRoot.super.processDecodes(context);
- }
-
- };
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processDecodes(javax.faces.context.FacesContext)
- */
- public void processDecodes(FacesContext context) {
- if (context == null)
- throw new NullPointerException("context");
- AjaxContext.invokeOnRegionOrRoot(this, context, _decodeInvoker,
- PhaseId.APPLY_REQUEST_VALUES);
- }
-
- private InvokerCallback _updatesInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- component.processUpdates(context);
- }
-
- public void invokeRoot(FacesContext context) {
- AjaxViewRoot.super.processUpdates(context);
- }
-
- };
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processUpdates(javax.faces.context.FacesContext)
- */
- public void processUpdates(FacesContext context) {
- if (context == null)
- throw new NullPointerException("context");
- AjaxContext.invokeOnRegionOrRoot(this, context, _updatesInvoker,
- PhaseId.UPDATE_MODEL_VALUES);
- }
-
- private InvokerCallback _validatorsInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- component.processValidators(context);
- }
-
- public void invokeRoot(FacesContext context) {
- AjaxViewRoot.super.processValidators(context);
- }
-
- };
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processValidators(javax.faces.context.FacesContext)
- */
- public void processValidators(FacesContext context) {
- if (context == null)
- throw new NullPointerException("context");
- AjaxContext.invokeOnRegionOrRoot(this, context, _validatorsInvoker,
- PhaseId.PROCESS_VALIDATIONS);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIViewRoot#processApplication(javax.faces.context.FacesContext)
- */
- public void processApplication(FacesContext context) {
- if (context == null)
- throw new NullPointerException("context");
- // UIComponent component = getSubmittedRegion(context);
- // TODO - process JSF 1.2 listeners
- broadcastEvents(context, PhaseId.INVOKE_APPLICATION);
- if (context.getRenderResponse() || context.getResponseComplete()) {
- clearEvents(context);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIViewRoot#encodeBegin(javax.faces.context.FacesContext)
- */
- // public void encodeBegin(FacesContext context) throws IOException {
- // UIComponent submittedComponent = getSubmittedRegion(context);
- // if(null == submittedComponent){
- // super.encodeBegin(context);
- // } else {
- // submittedComponent.encodeBegin(context);
- // }
- // }
-
- private InvokerCallback _ajaxInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- try {
- if (component instanceof AjaxContainer) {
- AjaxContainer ajax = (AjaxContainer) component;
- ajax.encodeAjax(context);
- } else {
- // Container not found, use Root for encode.
- encodeAjax(context);
- }
- } catch (IOException e) {
- throw new FacesException(e);
- }
- }
-
- public void invokeRoot(FacesContext context) {
- try {
- encodeAjax(context);
- } catch (IOException e) {
- throw new FacesException(e);
- }
- }
-
- };
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
- */
- public void encodeChildren(FacesContext context) throws IOException {
- if ( !isHavePage() &&
AjaxContext.getCurrentInstance(context).isAjaxRequest(context)) {
- AjaxContext.invokeOnRegionOrRoot(this, context, _ajaxInvoker,
- PhaseId.RENDER_RESPONSE);
- } else {
- super.encodeChildren(context);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#encodeEnd(javax.faces.context.FacesContext)
- */
-// public void encodeEnd(FacesContext context) throws IOException {
-// UIComponent submittedComponent = getSubmittedRegion(context);
-// if (null == submittedComponent) {
-// super.encodeEnd(context);
-// } else {
-// submittedComponent.encodeEnd(context);
-// }
-// }
-
- public void restoreState(FacesContext context, Object state) {
- Object[] mystate = (Object[]) state;
- super.restoreState(context, mystate[0]);
- getBrige().restoreState(context, mystate[1]);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- Object[] state = new Object[2];
- state[0] = super.saveState(context);
- state[1] = getBrige().saveState(context);
- return state;
- }
-
- public String getViewId() {
- ViewIdHolder viewIdHolder = AjaxContext.getCurrentInstance()
- .getViewIdHolder();
- String viewId;
- if (null != viewIdHolder) {
- viewId = viewIdHolder.getViewId();
- } else {
- viewId = super.getViewId();
- }
- return viewId;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#setAjaxListener(javax.faces.el.MethodBinding)
- */
- public void setAjaxListener(MethodBinding ajaxListener) {
- getBrige().setAjaxListener(ajaxListener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setImmediate(boolean)
- */
- public void setImmediate(boolean immediate) {
- getBrige().setImmediate(immediate);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSubmitted(boolean)
- */
- public void setSubmitted(boolean submitted) {
- getBrige().setSubmitted(submitted);
- }
-
- public void addAjaxListener(AjaxListener listener) {
- addFacesListener(listener);
- }
-
- public AjaxListener[] getAjaxListeners() {
- return (AjaxListener[]) getFacesListeners(AjaxListener.class);
- }
-
- public void removeAjaxListener(AjaxListener listener) {
- removeFacesListener(listener);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSelfRendered()
- */
- public boolean isSelfRendered() {
- return false;// _brige.isSelfRendered();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSelfRendered(boolean)
- */
- public void setSelfRendered(boolean selfRendered) {
- // _brige.setSelfRendered(selfRendered);
- }
-
- /**
- * Check for AjaxContainer component in childreh. This is workaround for
- * MyFaces JSP tag implementation, not called any encode... methods in
- * <f:view> tag. If only one AjaxContainer present as children for viewRoot,
- * decoding methods delegated to them.
- *
- * @return Returns the havePage.
- */
- public boolean isHavePage() {
- return (getChildCount() == 1 && getChildren().get(0) instanceof
AjaxContainer);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#getRendersChildren()
- */
- public boolean getRendersChildren() {
- FacesContext context = FacesContext.getCurrentInstance();
- // For non Ajax request, view root not render children
- if (!AjaxContext.getCurrentInstance(context).isAjaxRequest(context)) {
- return false;
- }
- // Also, if have page component as clild - delegate rendering of
- // children to it.
- if (isHavePage()) {
- return false;
- }
- // Ajax Request. Control all output.
- return true;
- }
-
- public boolean isRenderRegionOnly() {
- // for viewroot it not applicable.
- return false;
- }
-
- public void setRenderRegionOnly(boolean reRenderPage) {
- // TODO Auto-generated method stub
-
- }
-
- public void encodeAjax(FacesContext context) throws IOException {
- String rendererType = getRendererType();
- if (rendererType != null) {
- ((AjaxContainerRenderer) getRenderer(context)).encodeAjax(context,
- this);
- }
-
- }
-
- /**
- * @return the brige
- */
- protected AjaxRegionBrige getBrige() {
- return _brige;
- }
-
-}
Copied:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java (from
rev 164, trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java)
===================================================================
--- tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,562 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.collections.Buffer;
+import org.apache.commons.collections.BufferUnderflowException;
+import org.apache.commons.collections.UnboundedFifoBuffer;
+
+/**
+ * Custom ViewRoot for support render parts of tree for Ajax requests. Main
+ * difference from default ViewRoot - store events queue and unique id counter
+ * in request-scope variables. In common realisation, store request-scope
+ * variables in component produce errors in case of concurrent requests to same
+ * view.
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.4 $ $Date: 2007/02/28 17:01:01 $
+ *
+ */
+public class AjaxViewRoot extends UIViewRoot implements AjaxContainer {
+
+ public static final String ROOT_ID = "_viewRoot";
+
+ private AjaxRegionBrige _brige;
+
+ /**
+ *
+ */
+ public AjaxViewRoot() {
+ super();
+ super.setId(ROOT_ID);
+ _brige = new AjaxRegionBrige(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#getId()
+ */
+ // public String getId() {
+ // return ROOT_ID;
+ // }
+ public String getRendererType() {
+ return (COMPONENT_FAMILY);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+ getBrige().broadcast(event);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#getAjaxListener()
+ */
+ public MethodBinding getAjaxListener() {
+ return getBrige().getAjaxListener();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isImmediate()
+ */
+ public boolean isImmediate() {
+ return getBrige().isImmediate();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSubmitted()
+ */
+ public boolean isSubmitted() {
+ return getBrige().isSubmitted();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponent#queueEvent(javax.faces.event.FacesEvent)
+ */
+ public void queueEvent(FacesEvent event) {
+ if (event == null)
+ throw new NullPointerException(Messages
+ .getMessage(Messages.NULL_EVENT_SUBMITTED_ERROR));
+ if (event.getPhaseId().compareTo(PhaseId.RENDER_RESPONSE) == 0) {
+ // HACK - Special case - Ajax Events to RenderResponse phase
+ // queue.
+ // in future, with JSF 1.2 it must be done by invokeOnComponent
+ // method.
+ // In 1.1 , events to RENDER_RESPONSE phase not used.
+ getAjaxEventsQueue(getFacesContext()).add(event);
+ } else {
+ getEventsQueue(getFacesContext(), event.getPhaseId()).add(event);
+ }
+ }
+
+ /**
+ * Broadcast events for specified Phase
+ *
+ * @param context
+ * @param phaseId -
+ * phase, for wich events must be processed.
+ */
+ void broadcastEvents(FacesContext context, PhaseId phaseId) {
+ Buffer[] events = getEvents(context);
+ Buffer anyPhaseEvents = events[PhaseId.ANY_PHASE.getOrdinal()];
+ Buffer phaseEvents = events[phaseId.getOrdinal()];
+ if (phaseEvents.isEmpty() && anyPhaseEvents.isEmpty())
+ return;
+ // FacesEvent event = null;
+ boolean haveAnyPhaseEvents = !anyPhaseEvents.isEmpty();
+ boolean havePhaseEvents = !phaseEvents.isEmpty();
+ do {
+ // ANY_PHASE first
+ processEvents(anyPhaseEvents, haveAnyPhaseEvents);
+
+ processEvents(phaseEvents, havePhaseEvents);
+ // Events can queued in other events processing
+ haveAnyPhaseEvents = !anyPhaseEvents.isEmpty();
+ havePhaseEvents = !phaseEvents.isEmpty();
+ } while (haveAnyPhaseEvents || havePhaseEvents);
+ if (context.getRenderResponse() || context.getResponseComplete()) {
+ clearEvents(context);
+ }
+
+ }
+
+ /**
+ * @param phaseEventsQueue
+ * @param havePhaseEvents
+ */
+ public void processEvents(Buffer phaseEventsQueue, boolean havePhaseEvents) {
+ FacesEvent event;
+ while (havePhaseEvents) {
+ try {
+ event = (FacesEvent) phaseEventsQueue.remove();
+ UIComponent source = event.getComponent();
+ try {
+ source.broadcast(event);
+ } catch (AbortProcessingException e) {
+ // abort event processing
+ // Page 3-30 of JSF 1.1 spec: "Throw an
+ // AbortProcessingException, to tell the JSF
+ // implementation
+ // that no further broadcast of this event, or any
+ // further
+ // events, should take place."
+ // clearEvents();
+ // return;
+ }
+ } catch (BufferUnderflowException e) {
+ havePhaseEvents = false;
+ }
+ }
+ }
+
+ public void broadcastAjaxEvents(FacesContext context) {
+ Buffer queue = getAjaxEventsQueue(context);
+ processEvents(queue, !queue.isEmpty());
+ }
+
+ private Buffer[] events;
+
+ private Buffer ajaxEvents = new UnboundedFifoBuffer();
+
+ /**
+ * Use FIFO buffers for hold Faces Events. Hold this buffers in Request
+ * scope parameters for support any concurrent requests for same
+ * component tree ( since RI hold component tree in session ).
+ *
+ * @param context
+ * @param phase
+ * @return
+ */
+ protected Buffer getEventsQueue(FacesContext context, PhaseId phase) {
+ return getEvents(context)[phase.getOrdinal()];
+ }
+
+ /**
+ * @return
+ */
+ protected Buffer[] getEvents(FacesContext context) {
+ if (events == null) {
+ clearEvents(context);
+ }
+ return events;
+ }
+
+ /**
+ * Special Fifo Buffer for ajax events to Render Responce phase.
+ *
+ * @param context
+ * @return
+ */
+ protected Buffer getAjaxEventsQueue(FacesContext context) {
+
+ return ajaxEvents;
+ }
+
+ public void clearEvents(FacesContext context) {
+ int len;
+ events = new Buffer[len = PhaseId.VALUES.size()];
+ for (int i = 0; i < len; i++) {
+ events[i] = new UnboundedFifoBuffer();
+ }
+ }
+
+ private InvokerCallback _decodeInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ component.processDecodes(context);
+ }
+
+ public void invokeRoot(FacesContext context) {
+ AjaxViewRoot.super.processDecodes(context);
+ }
+
+ };
+
+ private UIComponent singleComponent = null;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processDecodes(javax.faces.context.FacesContext)
+ */
+ public void processDecodes(FacesContext context) {
+ if (context == null)
+ throw new NullPointerException("context");
+ singleComponent = null;
+ AjaxContext.invokeOnRegionOrRoot(this, context, _decodeInvoker);
+ try {
+ broadcastEvents(context, PhaseId.APPLY_REQUEST_VALUES);
+ } catch (AjaxSingleException e) {
+ singleComponent = e.getComponent();
+ }
+ }
+
+ private InvokerCallback _updatesInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ component.processUpdates(context);
+ }
+
+ public void invokeRoot(FacesContext context) {
+ AjaxViewRoot.super.processUpdates(context);
+ }
+
+ };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processUpdates(javax.faces.context.FacesContext)
+ */
+ public void processUpdates(FacesContext context) {
+ if (context == null)
+ throw new NullPointerException("context");
+ if (null == singleComponent) {
+ AjaxContext.invokeOnRegionOrRoot(this, context, _updatesInvoker);
+ } else {
+ singleComponent.processUpdates(context);
+ }
+ broadcastEvents(context, PhaseId.UPDATE_MODEL_VALUES);
+ }
+
+ private InvokerCallback _validatorsInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ component.processValidators(context);
+ }
+
+ public void invokeRoot(FacesContext context) {
+ AjaxViewRoot.super.processValidators(context);
+ }
+
+ };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processValidators(javax.faces.context.FacesContext)
+ */
+ public void processValidators(FacesContext context) {
+ if (context == null)
+ throw new NullPointerException("context");
+ if (null == singleComponent) {
+ AjaxContext.invokeOnRegionOrRoot(this, context, _validatorsInvoker);
+ } else {
+ singleComponent.processValidators(context);
+ }
+ broadcastEvents(context, PhaseId.PROCESS_VALIDATIONS);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIViewRoot#processApplication(javax.faces.context.FacesContext)
+ */
+ public void processApplication(FacesContext context) {
+ if (context == null)
+ throw new NullPointerException("context");
+ // UIComponent component = getSubmittedRegion(context);
+ // TODO - process JSF 1.2 listeners
+ broadcastEvents(context, PhaseId.INVOKE_APPLICATION);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIViewRoot#encodeBegin(javax.faces.context.FacesContext)
+ */
+ // public void encodeBegin(FacesContext context) throws IOException {
+ // UIComponent submittedComponent = getSubmittedRegion(context);
+ // if(null == submittedComponent){
+ // super.encodeBegin(context);
+ // } else {
+ // submittedComponent.encodeBegin(context);
+ // }
+ // }
+ private InvokerCallback _ajaxInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ try {
+ if (component instanceof AjaxContainer) {
+ AjaxContainer ajax = (AjaxContainer) component;
+ ajax.encodeAjax(context);
+ } else {
+ // Container not found, use Root for encode.
+ encodeAjax(context);
+ }
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ public void invokeRoot(FacesContext context) {
+ try {
+ encodeAjax(context);
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
+ */
+ public void encodeChildren(FacesContext context) throws IOException {
+ if (!isHavePage()
+ && AjaxContext.getCurrentInstance(context).isAjaxRequest(
+ context)) {
+ AjaxContext.invokeOnRegionOrRoot(this, context, _ajaxInvoker);
+ } else {
+ super.encodeChildren(context);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#encodeEnd(javax.faces.context.FacesContext)
+ */
+ // public void encodeEnd(FacesContext context) throws IOException {
+ // UIComponent submittedComponent = getSubmittedRegion(context);
+ // if (null == submittedComponent) {
+ // super.encodeEnd(context);
+ // } else {
+ // submittedComponent.encodeEnd(context);
+ // }
+ // }
+ public void restoreState(FacesContext context, Object state) {
+ Object[] mystate = (Object[]) state;
+ super.restoreState(context, mystate[0]);
+ getBrige().restoreState(context, mystate[1]);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[2];
+ state[0] = super.saveState(context);
+ state[1] = getBrige().saveState(context);
+ return state;
+ }
+
+ public String getViewId() {
+ ViewIdHolder viewIdHolder = AjaxContext.getCurrentInstance()
+ .getViewIdHolder();
+ String viewId;
+ if (null != viewIdHolder) {
+ viewId = viewIdHolder.getViewId();
+ } else {
+ viewId = super.getViewId();
+ }
+ return viewId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#setAjaxListener(javax.faces.el.MethodBinding)
+ */
+ public void setAjaxListener(MethodBinding ajaxListener) {
+ getBrige().setAjaxListener(ajaxListener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setImmediate(boolean)
+ */
+ public void setImmediate(boolean immediate) {
+ getBrige().setImmediate(immediate);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSubmitted(boolean)
+ */
+ public void setSubmitted(boolean submitted) {
+ getBrige().setSubmitted(submitted);
+ }
+
+ public void addAjaxListener(AjaxListener listener) {
+ addFacesListener(listener);
+ }
+
+ public AjaxListener[] getAjaxListeners() {
+ return (AjaxListener[]) getFacesListeners(AjaxListener.class);
+ }
+
+ public void removeAjaxListener(AjaxListener listener) {
+ removeFacesListener(listener);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSelfRendered()
+ */
+ public boolean isSelfRendered() {
+ return false;// _brige.isSelfRendered();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSelfRendered(boolean)
+ */
+ public void setSelfRendered(boolean selfRendered) {
+ // _brige.setSelfRendered(selfRendered);
+ }
+
+ /**
+ * Check for AjaxContainer component in childreh. This is workaround for
+ * MyFaces JSP tag implementation, not called any encode... methods in
+ * <f:view> tag. If only one AjaxContainer present as children for
+ * viewRoot, decoding methods delegated to them.
+ *
+ * @return Returns the havePage.
+ */
+ public boolean isHavePage() {
+ return (getChildCount() == 1 && getChildren().get(0) instanceof AjaxContainer);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ // For non Ajax request, view root not render children
+ if (!AjaxContext.getCurrentInstance(context).isAjaxRequest(context)) {
+ return false;
+ }
+ // Also, if have page component as clild - delegate rendering of
+ // children to it.
+ if (isHavePage()) {
+ return false;
+ }
+ // Ajax Request. Control all output.
+ return true;
+ }
+
+ public boolean isRenderRegionOnly() {
+ // for viewroot it not applicable.
+ return false;
+ }
+
+ public void setRenderRegionOnly(boolean reRenderPage) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void encodeAjax(FacesContext context) throws IOException {
+ String rendererType = getRendererType();
+ if (rendererType != null) {
+ ((AjaxContainerRenderer) getRenderer(context)).encodeAjax(context,
+ this);
+ }
+
+ }
+
+ /**
+ * @return the brige
+ */
+ protected AjaxRegionBrige getBrige() {
+ return _brige;
+ }
+
+}
Deleted:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/ComponentInvoker.java
===================================================================
---
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/ComponentInvoker.java 2007-05-02
17:40:09 UTC (rev 158)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/ComponentInvoker.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -1,57 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseId;
-
-/**
- * Interface for call lifecycle methods on component with known clientId
- * For JSF 1.2 implementation must use invokeOnComponent method, for JSF 1.1 use
- * simple recursion on view tree ( not compatible with UIData components )
- * @author shura
- *
- */
-public interface ComponentInvoker {
-
- /**
- * Invoke method on active AjaxContainer component, or on viewRoot, if none.
- * @param viewRoot
- * @param context
- * @param callback
- * @param phase
- */
- public abstract void invokeOnRegionOrRoot(AjaxViewRoot viewRoot,
- FacesContext context, InvokerCallback callback, PhaseId phase);
-
- /**
- * Recursive call for all children for search component with same clientId as target
region
- * @param viewRoot
- * @param context
- * @param callback
- * @param regionId
- */
- public abstract boolean invokeOnComponent(UIComponent root,
- FacesContext context, InvokerCallback callback, String regionId);
-
-}
\ No newline at end of file
Copied:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/ComponentInvoker.java
(from rev 164,
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/ComponentInvoker.java)
===================================================================
---
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/ComponentInvoker.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/ComponentInvoker.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * Interface for call lifecycle methods on component with known clientId
+ * For JSF 1.2 implementation must use invokeOnComponent method, for JSF 1.1 use
+ * simple recursion on view tree ( not compatible with UIData components )
+ * @author shura
+ *
+ */
+public interface ComponentInvoker {
+
+ /**
+ * Invoke method on active AjaxContainer component, or on viewRoot, if none.
+ * @param viewRoot
+ * @param context
+ * @param callback
+ */
+ public abstract void invokeOnRegionOrRoot(AjaxViewRoot viewRoot,
+ FacesContext context, InvokerCallback callback);
+
+ /**
+ * Recursive call for all children for search component with same clientId as target
region
+ * @param viewRoot
+ * @param context
+ * @param callback
+ * @param regionId
+ */
+ public abstract boolean invokeOnComponent(UIComponent root,
+ FacesContext context, InvokerCallback callback, String regionId);
+
+}
\ No newline at end of file
Deleted:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/JsfOneOneInvoker.java
===================================================================
---
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/JsfOneOneInvoker.java 2007-05-02
17:40:09 UTC (rev 158)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/JsfOneOneInvoker.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -1,90 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.util.Iterator;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseId;
-
-/**
- * @author shura
- *
- */
-public class JsfOneOneInvoker implements ComponentInvoker {
-
-
- /**
- *
- */
- public JsfOneOneInvoker() {
- // TODO Auto-generated constructor stub
- }
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.ajax.AjaxInvoker#invokeOnRegionOrRoot(org.ajax4jsf.framework.ajax.AjaxViewRoot,
javax.faces.context.FacesContext, org.ajax4jsf.framework.ajax.InvokerCallback,
javax.faces.event.PhaseId)
- */
- public void invokeOnRegionOrRoot(AjaxViewRoot viewRoot, FacesContext context,
InvokerCallback callback, PhaseId phase) {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- String submittedRegionClientId = ajaxContext.getSubmittedRegionClientId(context);
- if(null == submittedRegionClientId ||
viewRoot.getId().equals(submittedRegionClientId)){
- // This is a not AJAX request, or active region is root.
- callback.invokeRoot(context);
- } else {
- if(!invokeOnComponent(viewRoot, context, callback, submittedRegionClientId)){
- // Region not found - perform default actions.
- // TODO - log errors.
- callback.invokeRoot(context);
- }
- }
- viewRoot.broadcastEvents(context, phase);
- if (context.getRenderResponse() || context.getResponseComplete()) {
- viewRoot.clearEvents(context);
- }
-
- }
-
- public void invokeOnRegion(FacesContext context, InvokerCallback callback, String
regionId) {
- UIViewRoot viewRoot = context.getViewRoot();
- invokeOnComponent(viewRoot,context,callback,regionId);
- }
- /* (non-Javadoc)
- * @see
org.ajax4jsf.framework.ajax.AjaxInvoker#invokeOnComponent(javax.faces.component.UIComponent,
javax.faces.context.FacesContext, org.ajax4jsf.framework.ajax.InvokerCallback,
java.lang.String)
- */
- public boolean invokeOnComponent(UIComponent root, FacesContext context, InvokerCallback
callback, String regionId) {
- if(regionId.equals(root.getClientId(context))){
- callback.invoke(context, root);
- return true;
- }
- for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- if(invokeOnComponent(child, context, callback, regionId)){
- return true;
- }
- }
- return false;
- }
-
-}
Copied:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/JsfOneOneInvoker.java
(from rev 164,
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/JsfOneOneInvoker.java)
===================================================================
---
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/JsfOneOneInvoker.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/JsfOneOneInvoker.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,87 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author shura
+ *
+ */
+public class JsfOneOneInvoker implements ComponentInvoker {
+
+
+ /**
+ *
+ */
+ public JsfOneOneInvoker() {
+ // TODO Auto-generated constructor stub
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.ajax.AjaxInvoker#invokeOnRegionOrRoot(org.ajax4jsf.framework.ajax.AjaxViewRoot,
javax.faces.context.FacesContext, org.ajax4jsf.framework.ajax.InvokerCallback,
javax.faces.event.PhaseId)
+ */
+ public void invokeOnRegionOrRoot(AjaxViewRoot viewRoot, FacesContext context,
InvokerCallback callback) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ String submittedRegionClientId = ajaxContext.getSubmittedRegionClientId(context);
+ if(null == submittedRegionClientId ||
viewRoot.getId().equals(submittedRegionClientId)){
+ // This is a not AJAX request, or active region is root.
+ callback.invokeRoot(context);
+ } else {
+ if(!invokeOnComponent(viewRoot, context, callback, submittedRegionClientId)){
+ // Region not found - perform default actions.
+ // TODO - log errors.
+ callback.invokeRoot(context);
+ }
+ }
+
+ }
+
+ public void invokeOnRegion(FacesContext context, InvokerCallback callback, String
regionId) {
+ UIViewRoot viewRoot = context.getViewRoot();
+ invokeOnComponent(viewRoot,context,callback,regionId);
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.ajax.AjaxInvoker#invokeOnComponent(javax.faces.component.UIComponent,
javax.faces.context.FacesContext, org.ajax4jsf.framework.ajax.InvokerCallback,
java.lang.String)
+ */
+ public boolean invokeOnComponent(UIComponent root, FacesContext context, InvokerCallback
callback, String regionId) {
+ if(regionId.equals(root.getClientId(context))){
+ callback.invoke(context, root);
+ return true;
+ }
+ for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if(invokeOnComponent(child, context, callback, regionId)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Deleted:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
===================================================================
---
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-05-02
17:40:09 UTC (rev 158)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -1,360 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.Date;
-import java.util.Enumeration;
-
-import javax.faces.application.ViewHandler;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.resource.InternetResourceService;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base class for request processing filters, with convert Htmp content to XML
- * for ajax requests, and serve request to application off-page resources
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:21 $
- *
- */
-public abstract class BaseFilter implements Filter {
-
- private static final Log log = LogFactory.getLog(BaseFilter.class);
-
- public static final boolean DEBUG = true;
-
- private FilterConfig filterConfig;
-
- private static final String FUNCTION_NAME_PARAMETER = "function";
-
- private String function = "alert('Data
received');JSHttpRequest.dataReady";
-
- private String attributesNames;
-
- private boolean rewriteid = false;
-
- private static final String REWRITEID_PARAMETER = "rewriteid";
-
- private static final String STYLESHEET_PARAMETER = "xsl";
-
- private static final String ABSOLUTE_TAGS_PARAMETER =
"absolute-attributes";
-
- // private WebXml webXml;
- // private String xsl;
- // private Templates xslTemplates;
- /**
- *
- */
- private static final long serialVersionUID = -2295534611886142935L;
-
- public static final String DATA_PARAMETER = "DATA";
-
- public static final String DEFAULT_SERVLET_PATH = "/resource";
-
- public static final String RENDERER_PREFIX = "/renderer";
-
- public static final String CACHEABLE_PREFIX = "/cache";
-
- // private static final Pattern rendererPattern =
- // Pattern.compile(RENDERER_PREFIX+"/([^/]+)/([^/]+)/([^/]+)/(.*)");
- // private static final Pattern builderPattern =
- // Pattern.compile(CACHEABLE_PREFIX+"/(.*)");
- public static final String FILTER_PERFORMED = "com.exade.vcp.Filter.done";
-
- public static final String RESPONSE_WRAPPER_ATTRIBUTE =
"com.exade.vcp.Filter.ResponseWrapper";
-
- protected BaseXMLFilter xmlFilter = null;
-
- InternetResourceService resourceService = null;
-
- /**
- * Initialize the filter.
- */
- public void init(FilterConfig config) throws ServletException {
- if(log.isDebugEnabled()){
- log.debug("Init ajax4jsf filter with nane: "+config.getFilterName());
- Enumeration parameterNames = config.getInitParameterNames();
- StringBuffer parameters = new StringBuffer("Init parameters :\n");
- while (parameterNames.hasMoreElements()) {
- String name = (String) parameterNames.nextElement();
- parameters.append(name).append(" :
'").append(config.getInitParameter(name)).append('\n');
- }
- log.debug(parameters);
-// log.debug("Stack Trace", new Exception());
- }
- // Save config
- filterConfig = config;
- setFunction((String) nz(filterConfig
- .getInitParameter(FUNCTION_NAME_PARAMETER), getFunction()));
- setAttributesNames(filterConfig
- .getInitParameter(ABSOLUTE_TAGS_PARAMETER));
- xmlFilter.init(config);
- if ("true".equalsIgnoreCase(filterConfig
- .getInitParameter(REWRITEID_PARAMETER))) {
- this.setRewriteid(true);
- }
-
- String prefix = filterConfig.getServletContext().getRealPath("/");
- String file = filterConfig.getInitParameter("log4j-init-file");
- // if the log4j-init-file is not set, then no point in trying
- if (file != null) {
- Log4JConfigurator log4jconfig = new Log4JConfigurator(prefix);
- log4jconfig.doConfigure(file);
- }
- resourceService = new InternetResourceService();
- // Caching initialization.
- resourceService.init(filterConfig);
- }
-
- /**
- * @param httpServletRequest
- * @throws UnsupportedEncodingException
- */
- protected void setupRequestEncoding(HttpServletRequest httpServletRequest)
- throws UnsupportedEncodingException {
- String contentType = httpServletRequest.getHeader("Content-Type");
-
- String characterEncoding = lookupCharacterEncoding(contentType);
-
- if (characterEncoding == null) {
- HttpSession session = httpServletRequest.getSession(false);
-
- if (session != null) {
- characterEncoding = (String) session
- .getAttribute(ViewHandler.CHARACTER_ENCODING_KEY);
- }
-
- if (characterEncoding != null) {
- httpServletRequest.setCharacterEncoding(characterEncoding);
- }
- }
- }
-
- /**
- * Detect request encoding from Content-Type header
- *
- * @param contentType
- * @return - charset, if present.
- */
- private String lookupCharacterEncoding(String contentType) {
- String characterEncoding = null;
-
- if (contentType != null) {
- int charsetFind = contentType.indexOf("charset=");
- if (charsetFind != -1) {
- if (charsetFind == 0) {
- // charset at beginning of Content-Type, curious
- characterEncoding = contentType.substring(8);
- } else {
- char charBefore = contentType.charAt(charsetFind - 1);
- if (charBefore == ';' || Character.isWhitespace(charBefore)) {
- // Correct charset after mime type
- characterEncoding = contentType
- .substring(charsetFind + 8);
- }
- }
- if (log.isDebugEnabled())
- log.debug(Messages.getMessage(
- Messages.CONTENT_TYPE_ENCODING, characterEncoding));
- } else {
- if (log.isDebugEnabled())
- log.debug(Messages.getMessage(
- Messages.CONTENT_TYPE_NO_ENCODING, contentType));
- }
- }
- return characterEncoding;
- }
-
- /**
- * @param initParameter
- * @param function2
- * @return
- */
- private Object nz(Object param, Object def) {
- return param != null ? param : def;
- }
-
- /**
- * Execute the filter.
- */
- public void doFilter(ServletRequest request, ServletResponse response,
- FilterChain chain) throws IOException, ServletException {
- long startTimeMills = 0;
- // Detect case of request - normal, AJAX, AJAX - JavaScript
- // TODO - detect first processing in filter.
- HttpServletRequest httpServletRequest = (HttpServletRequest) request;
- HttpServletResponse httpServletResponse = (HttpServletResponse) response;
- if (log.isDebugEnabled()) {
- startTimeMills = System.currentTimeMillis();
- log.debug(Messages.getMessage(Messages.FILTER_START_INFO, new Date(
- startTimeMills), httpServletRequest.getRequestURI()));
- }
-
- if (request.getAttribute(FILTER_PERFORMED) != Boolean.TRUE) {
- // mark - and not processing same request twice.
- request.setAttribute(FILTER_PERFORMED, Boolean.TRUE);
- // check for resource request
- if (!getResourceService().serviceResource(httpServletRequest,
- httpServletResponse)) {
- // Not request to resource - perform filtering.
- // first stage - detect/set encoding of request. Same as in
- // Myfaces External Context.
- setupRequestEncoding(httpServletRequest);
- // check ajax request parameter
- // TODO - check for JSF page.
- if (true) {
- if (log.isDebugEnabled()) {
- log.debug(Messages
- .getMessage(Messages.FILTER_XML_OUTPUT));
- }
-
- // Execute the rest of the filter chain, including the
- // JSP
- xmlFilter.doXmlFilter(chain, httpServletRequest,
- httpServletResponse);
- } else {
- // normal request, execute chain ...
- if (log.isDebugEnabled()) {
- log.debug(Messages
- .getMessage(Messages.FILTER_NO_XML_CHAIN));
- }
- chain.doFilter(request, response);
-
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.FILTER_NO_XML_CHAIN_2));
- }
- chain.doFilter(request, response);
-
- }
- if (log.isDebugEnabled()) {
- startTimeMills = System.currentTimeMillis() - startTimeMills;
- log.debug(Messages.getMessage(Messages.FILTER_STOP_INFO, ""
- + startTimeMills, httpServletRequest.getRequestURI()));
- }
- }
-
- /**
- * @param request
- * @return
- */
- protected boolean isAjaxRequest(ServletRequest request) {
- try {
- return null != request
- .getParameter(AjaxContainerRenderer.AJAX_PARAMETER_NAME);
- } catch (Exception e) {
- // OCJ 10 - throw exception for static resources.
- return false;
- }
- }
-
- /**
- * Destroy the filter.
- */
- public void destroy() {
- }
-
- /**
- * @return Returns the servletContext.
- */
- ServletContext getServletContext() {
- return filterConfig.getServletContext();
- }
-
- /**
- * @return the resourceService
- * @throws ServletException
- */
- protected synchronized InternetResourceService getResourceService()
- throws ServletException {
-// if (resourceService == null) {
-// resourceService = new InternetResourceService();
-// // Caching initialization.
-// resourceService.init(filterConfig);
-//
-// }
- return resourceService;
- }
-
- /**
- * @param function
- * The function to set.
- */
- protected void setFunction(String function) {
- this.function = function;
- }
-
- /**
- * @return Returns the function.
- */
- protected String getFunction() {
- return function;
- }
-
- /**
- * @param rewriteid
- * The rewriteid to set.
- */
- protected void setRewriteid(boolean rewriteid) {
- this.rewriteid = rewriteid;
- }
-
- /**
- * @return Returns the rewriteid.
- */
- protected boolean isRewriteid() {
- return rewriteid;
- }
-
- /**
- * @param attributesNames
- * The attributesNames to set.
- */
- protected void setAttributesNames(String attributesNames) {
- this.attributesNames = attributesNames;
- }
-
- /**
- * @return Returns the attributesNames.
- */
- protected String getAttributesNames() {
- return attributesNames;
- }
-}
Copied:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
(from rev 164,
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java)
===================================================================
---
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,389 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax.xmlfilter;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.util.Enumeration;
+
+import javax.faces.application.ViewHandler;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.ajax4jsf.ajax.PushEventsCounter;
+import org.ajax4jsf.cache.Cache;
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.framework.resource.InternetResourceService;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base class for request processing filters, with convert Htmp content to XML
+ * for ajax requests, and serve request to application off-page resources
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:21 $
+ *
+ */
+public abstract class BaseFilter implements Filter {
+
+ private static final String AJAX_PUSH_KEY_HEADER = "Ajax-Push-Key";
+
+ private static final Log log = LogFactory.getLog(BaseFilter.class);
+
+ public static final boolean DEBUG = true;
+
+ private FilterConfig filterConfig;
+
+ private static final String FUNCTION_NAME_PARAMETER = "function";
+
+ private String function = "alert('Data
received');JSHttpRequest.dataReady";
+
+ private String attributesNames;
+
+ private boolean rewriteid = false;
+
+ private static final String REWRITEID_PARAMETER = "rewriteid";
+
+ private static final String STYLESHEET_PARAMETER = "xsl";
+
+ private static final String ABSOLUTE_TAGS_PARAMETER =
"absolute-attributes";
+
+ // private WebXml webXml;
+ // private String xsl;
+ // private Templates xslTemplates;
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2295534611886142935L;
+
+ public static final String DATA_PARAMETER = "DATA";
+
+ public static final String DEFAULT_SERVLET_PATH = "/resource";
+
+ public static final String RENDERER_PREFIX = "/renderer";
+
+ public static final String CACHEABLE_PREFIX = "/cache";
+
+ // private static final Pattern rendererPattern =
+ // Pattern.compile(RENDERER_PREFIX+"/([^/]+)/([^/]+)/([^/]+)/(.*)");
+ // private static final Pattern builderPattern =
+ // Pattern.compile(CACHEABLE_PREFIX+"/(.*)");
+ public static final String FILTER_PERFORMED = "com.exade.vcp.Filter.done";
+
+ public static final String RESPONSE_WRAPPER_ATTRIBUTE =
"com.exade.vcp.Filter.ResponseWrapper";
+
+ protected BaseXMLFilter xmlFilter = null;
+
+ protected InternetResourceService resourceService = null;
+
+ protected PollEventsManager eventsManager;
+
+ /**
+ * Initialize the filter.
+ */
+ public void init(FilterConfig config) throws ServletException {
+ if (log.isDebugEnabled()) {
+ log.debug("Init ajax4jsf filter with nane: "
+ + config.getFilterName());
+ Enumeration parameterNames = config.getInitParameterNames();
+ StringBuffer parameters = new StringBuffer("Init parameters :\n");
+ while (parameterNames.hasMoreElements()) {
+ String name = (String) parameterNames.nextElement();
+ parameters.append(name).append(" : '").append(
+ config.getInitParameter(name)).append('\n');
+ }
+ log.debug(parameters);
+ // log.debug("Stack Trace", new Exception());
+ }
+ // Save config
+ filterConfig = config;
+ setFunction((String) nz(filterConfig
+ .getInitParameter(FUNCTION_NAME_PARAMETER), getFunction()));
+ setAttributesNames(filterConfig
+ .getInitParameter(ABSOLUTE_TAGS_PARAMETER));
+ xmlFilter.init(config);
+ if ("true".equalsIgnoreCase(filterConfig
+ .getInitParameter(REWRITEID_PARAMETER))) {
+ this.setRewriteid(true);
+ }
+
+ String prefix = filterConfig.getServletContext().getRealPath("/");
+ String file = filterConfig.getInitParameter("log4j-init-file");
+ // if the log4j-init-file is not set, then no point in trying
+ if (file != null) {
+ Log4JConfigurator log4jconfig = new Log4JConfigurator(prefix);
+ log4jconfig.doConfigure(file);
+ }
+ resourceService = new InternetResourceService();
+ // Caching initialization.
+ resourceService.init(filterConfig);
+ eventsManager = new PollEventsManager();
+ eventsManager.init(filterConfig.getServletContext());
+ }
+
+ /**
+ * @param httpServletRequest
+ * @throws UnsupportedEncodingException
+ */
+ protected void setupRequestEncoding(HttpServletRequest httpServletRequest)
+ throws UnsupportedEncodingException {
+ String contentType = httpServletRequest.getHeader("Content-Type");
+
+ String characterEncoding = lookupCharacterEncoding(contentType);
+
+ if (characterEncoding == null) {
+ HttpSession session = httpServletRequest.getSession(false);
+
+ if (session != null) {
+ characterEncoding = (String) session
+ .getAttribute(ViewHandler.CHARACTER_ENCODING_KEY);
+ }
+
+ if (characterEncoding != null) {
+ httpServletRequest.setCharacterEncoding(characterEncoding);
+ }
+ }
+ }
+
+ /**
+ * Detect request encoding from Content-Type header
+ *
+ * @param contentType
+ * @return - charset, if present.
+ */
+ private String lookupCharacterEncoding(String contentType) {
+ String characterEncoding = null;
+
+ if (contentType != null) {
+ int charsetFind = contentType.indexOf("charset=");
+ if (charsetFind != -1) {
+ if (charsetFind == 0) {
+ // charset at beginning of Content-Type, curious
+ characterEncoding = contentType.substring(8);
+ } else {
+ char charBefore = contentType.charAt(charsetFind - 1);
+ if (charBefore == ';' || Character.isWhitespace(charBefore)) {
+ // Correct charset after mime type
+ characterEncoding = contentType
+ .substring(charsetFind + 8);
+ }
+ }
+ if (log.isDebugEnabled())
+ log.debug(Messages.getMessage(
+ Messages.CONTENT_TYPE_ENCODING, characterEncoding));
+ } else {
+ if (log.isDebugEnabled())
+ log.debug(Messages.getMessage(
+ Messages.CONTENT_TYPE_NO_ENCODING, contentType));
+ }
+ }
+ return characterEncoding;
+ }
+
+ /**
+ * @param initParameter
+ * @param function2
+ * @return
+ */
+ private Object nz(Object param, Object def) {
+ return param != null ? param : def;
+ }
+
+ /**
+ * Execute the filter.
+ */
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain) throws IOException, ServletException {
+ long startTimeMills = 0;
+ // Detect case of request - normal, AJAX, AJAX - JavaScript
+ // TODO - detect first processing in filter.
+ HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+ HttpServletResponse httpServletResponse = (HttpServletResponse) response;
+ if (log.isDebugEnabled()) {
+ startTimeMills = System.currentTimeMillis();
+ log.debug(Messages.getMessage(Messages.FILTER_START_INFO, new Date(
+ startTimeMills), httpServletRequest.getRequestURI()));
+ }
+
+ if (request.getAttribute(FILTER_PERFORMED) != Boolean.TRUE) {
+ // mark - and not processing same request twice.
+ request.setAttribute(FILTER_PERFORMED, Boolean.TRUE);
+ String ajaxPushHeader = httpServletRequest.getHeader(AJAX_PUSH_KEY_HEADER);
+ // check for a push check request.
+ if (httpServletRequest.getMethod().equals("HEAD")
+ && null != ajaxPushHeader) {
+ PushEventsCounter listener = eventsManager.getListener(ajaxPushHeader);
+ if(listener.isPerformed()){
+ listener.processed();
+ httpServletResponse.setStatus(200);
+ if (log.isDebugEnabled()) {
+ log.debug("Occurs event for a id "+ajaxPushHeader);
+ }
+ } else {
+ // Response code - 'No content'
+ httpServletResponse.setStatus(204);
+ if (log.isDebugEnabled()) {
+ log.debug("No event for a id "+ajaxPushHeader);
+ }
+ }
+ } else
+ // check for resource request
+ if (!getResourceService().serviceResource(httpServletRequest,
+ httpServletResponse)) {
+ // Not request to resource - perform filtering.
+ // first stage - detect/set encoding of request. Same as in
+ // Myfaces External Context.
+ setupRequestEncoding(httpServletRequest);
+ // check ajax request parameter
+ // TODO - check for JSF page.
+ if (true) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages
+ .getMessage(Messages.FILTER_XML_OUTPUT));
+ }
+
+ // Execute the rest of the filter chain, including the
+ // JSP
+ xmlFilter.doXmlFilter(chain, httpServletRequest,
+ httpServletResponse);
+ } else {
+ // normal request, execute chain ...
+ if (log.isDebugEnabled()) {
+ log.debug(Messages
+ .getMessage(Messages.FILTER_NO_XML_CHAIN));
+ }
+ chain.doFilter(request, response);
+
+ }
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.FILTER_NO_XML_CHAIN_2));
+ }
+ chain.doFilter(request, response);
+
+ }
+ if (log.isDebugEnabled()) {
+ startTimeMills = System.currentTimeMillis() - startTimeMills;
+ log.debug(Messages.getMessage(Messages.FILTER_STOP_INFO, ""
+ + startTimeMills, httpServletRequest.getRequestURI()));
+ }
+ }
+
+ /**
+ * @param request
+ * @return
+ */
+ protected boolean isAjaxRequest(ServletRequest request) {
+ try {
+ return null != request
+ .getParameter(AjaxContainerRenderer.AJAX_PARAMETER_NAME);
+ } catch (Exception e) {
+ // OCJ 10 - throw exception for static resources.
+ return false;
+ }
+ }
+
+ /**
+ * Destroy the filter.
+ */
+ public void destroy() {
+ }
+
+ /**
+ * @return Returns the servletContext.
+ */
+ ServletContext getServletContext() {
+ return filterConfig.getServletContext();
+ }
+
+ /**
+ * @return the resourceService
+ * @throws ServletException
+ */
+ protected synchronized InternetResourceService getResourceService()
+ throws ServletException {
+ // if (resourceService == null) {
+ // resourceService = new InternetResourceService();
+ // // Caching initialization.
+ // resourceService.init(filterConfig);
+ //
+ // }
+ return resourceService;
+ }
+
+ /**
+ * @param function
+ * The function to set.
+ */
+ protected void setFunction(String function) {
+ this.function = function;
+ }
+
+ /**
+ * @return Returns the function.
+ */
+ protected String getFunction() {
+ return function;
+ }
+
+ /**
+ * @param rewriteid
+ * The rewriteid to set.
+ */
+ protected void setRewriteid(boolean rewriteid) {
+ this.rewriteid = rewriteid;
+ }
+
+ /**
+ * @return Returns the rewriteid.
+ */
+ protected boolean isRewriteid() {
+ return rewriteid;
+ }
+
+ /**
+ * @param attributesNames
+ * The attributesNames to set.
+ */
+ protected void setAttributesNames(String attributesNames) {
+ this.attributesNames = attributesNames;
+ }
+
+ /**
+ * @return Returns the attributesNames.
+ */
+ protected String getAttributesNames() {
+ return attributesNames;
+ }
+}
Copied:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/PollEventsManager.java
(from rev 164,
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/PollEventsManager.java)
===================================================================
---
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/PollEventsManager.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/PollEventsManager.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,64 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.ajax.xmlfilter;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.faces.FacesException;
+import javax.servlet.ServletContext;
+
+import org.ajax4jsf.ajax.PushEventsCounter;
+import org.ajax4jsf.cache.Cache;
+import org.ajax4jsf.cache.CacheConfigurationLoader;
+import org.ajax4jsf.cache.CacheException;
+import org.ajax4jsf.cache.CacheFactory;
+import org.ajax4jsf.cache.CacheLoader;
+import org.ajax4jsf.cache.CacheManager;
+import org.ajax4jsf.cache.ServletContextInitMap;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class PollEventsManager implements Serializable, CacheLoader,
CacheConfigurationLoader {
+
+ public static final String EVENTS_MANAGER_KEY=PollEventsManager.class.getName();
+
+ private Cache cache;
+
+ public void init(ServletContext servletContext) {
+ try {
+ CacheManager cacheManager = CacheManager.getInstance();
+ Map env = new ServletContextInitMap(servletContext);
+ CacheFactory cacheFactory = cacheManager.getCacheFactory(env);
+ this.cache = cacheFactory.createCache(env, this, this);
+ servletContext.setAttribute(EVENTS_MANAGER_KEY, this);
+ } catch (CacheException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+
+ }
+
+ public PushEventsCounter getListener(String key){
+ if(null == cache){
+ throw new FacesException("Poll events manager not initialized");
+ }
+ try {
+ return (PushEventsCounter) cache.get(key, null);
+ } catch (CacheException e) {
+ throw new FacesException("error get push events listener for key
"+key,e);
+ }
+ }
+
+ public Object load(Object key, Object context) throws CacheException {
+ // TODO Auto-generated method stub
+ return new PushEventsCounter();
+ }
+
+ public Properties loadProperties(String name) {
+ return new Properties();
+ }
+}
Deleted:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
===================================================================
---
trunk/framework/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2007-05-02
17:40:09 UTC (rev 158)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -1,935 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.application.ViewHandler;
-import javax.faces.component.ActionSource;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.component.UIParameter;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.ajax.UILoadBundle;
-import org.ajax4jsf.framework.ajax.AjaxComponent;
-import org.ajax4jsf.framework.ajax.AjaxContainer;
-import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.AjaxSupport;
-import org.ajax4jsf.framework.ajax.AjaxViewRoot;
-import org.ajax4jsf.framework.ajax.JavaScriptParameter;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.util.ServicesUtils;
-import org.ajax4jsf.framework.util.javascript.JSFunction;
-import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
-import org.ajax4jsf.framework.util.javascript.JSReference;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura
- *
- * Some utilites for render AJAX components.
- */
-public class AjaxRendererUtils {
-
- /**
- * Name Javasript function for submit AJAX request
- */
- public static final String AJAX_FUNCTION_NAME = "A4J.AJAX.Submit";
-
- /**
- * Attribute for keep clientId of status component
- */
- public static final String STATUS_ATTR_NAME = "status";
-
- /**
- * Attribute for keep JavaScript funtion name for call after complete
- * request.
- */
- public static final String ONCOMPLETE_ATTR_NAME = "oncomplete";
-
- /**
- * Attribute to keep
- */
- public static final String LIMITTOLIST_ATTR_NAME = "limitToList";
-
- private static Log log = LogFactory.getLog(AjaxRendererUtils.class);
-
- public static final String AJAX_REGIONS_ATTRIBUTE = "reRender";
-
- private static final Class OBJECT_ARRAY_CLASS = (new Object[0]).getClass();
-
- public static final String SEQUENCE_PARAM = "jsf_sequence";
-
- private static final String VALUE_ATTR = "value";
-
- public static final String AJAX_AREAS_RENDERED =
"org.ajax4jsf.areas.rendered";
-
- private static final String AJAX_SINGLE_ATTR = "ajaxSingle";
-
- public static final String AJAX_QUEUE_ATTR = "eventsQueue";
-
- public static final String AJAX_DELAY_ATTR = "requestDelay";
-
- private static final Object AJAX_ABORT_ATTR = "ignoreDupResponses";
-
- /**
- * Static class - protect constructor TODO - make as subclass of chameleon
- * RendererUtils.
- *
- */
- private AjaxRendererUtils() {
-
- }
-
- /**
- * Build JavaScript onclick event for given component
- *
- * @param uiComponent -
- * component for build event
- * @param facesContext
- * @return <code>StringBuffer</code> with Javascript code
- */
- public static StringBuffer buildOnClick(UIComponent uiComponent,
- FacesContext facesContext) {
- return buildOnEvent(uiComponent, facesContext, HTML.onclick_ATTRIBUTE);
- }
-
- /**
- * Build JavaScript event for component
- *
- * @param uiComponent -
- * component for build event
- * @param facesContext
- * @param eventName -
- * name of event
- * @return <code>StringBuffer</code> with Javascript code TODO - for
- * key-based events build list of supported keys
- */
- public static StringBuffer buildOnEvent(UIComponent uiComponent,
- FacesContext facesContext, String eventName) {
- StringBuffer onEvent = new StringBuffer();
- if (null != eventName) {
- String commandOnEvent = (String) uiComponent.getAttributes().get(
- eventName);
- if (commandOnEvent != null) {
- onEvent.append(commandOnEvent);
- onEvent.append(';');
- }
- }
- JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext);
- // Create formal parameter for non-input elements ???
- // Link Control pseudo-object
- // Options map. Possible options for function call :
- // control - name of form control for submit.
- // name - name for link control \
- // value - value of control. - possible replace by parameters ?
- // single true/false - submit all form or only one control.
- // affected - array of element's ID for update on responce.
- // oncomplete - function for call after complete request.
- // status - id of request status component.
- // parameters - map of parameters name/value for append on request.
- // TODO
- // sync true/false - run script in sync mode.
- // ..........
- ajaxFunction.addParameter(buildEventOptions(facesContext, uiComponent));
-
- // appendAjaxSubmitParameters(facesContext, uiComponent, onEvent);
- ajaxFunction.appendScript(onEvent);
- if (uiComponent instanceof AjaxSupport) {
- AjaxSupport support = (AjaxSupport) uiComponent;
- if (support.isDisableDefault()) {
- onEvent.append("; return false;");
- }
- }
- log.debug(Messages.getMessage(Messages.BUILD_ONCLICK_INFO, uiComponent
- .getId(), onEvent.toString()));
- return onEvent;
-
- }
-
- /**
- * @param facesContext
- * @param uiComponent
- * @return
- */
- public static Map buildEventOptions(FacesContext facesContext,
- UIComponent uiComponent) {
- String clientId = uiComponent.getClientId(facesContext);
- Map componentAttributes = uiComponent.getAttributes();
- Map options = new HashMap();
- Map parameters = new HashMap();
- // UIForm form = getNestingForm(uiComponent);
- // "input" - if assigned to html input element.
- boolean input = (uiComponent instanceof AjaxSupport && uiComponent
- .getParent() instanceof EditableValueHolder)
- || uiComponent instanceof EditableValueHolder;
- // Action component - button etc.
- boolean action = (uiComponent instanceof AjaxSupport && uiComponent
- .getParent() instanceof ActionSource)
- || uiComponent instanceof ActionSource;
- // TODO - disable ( or not ? ) submission of action for disabled default
- // ?
- // if ( action && uiComponent instanceof AjaxSupport) {
- // AjaxSupport support = (AjaxSupport) uiComponent;
- // if (support.isDisableDefault()) {
- // action = false;
- // }
- // }
-
- boolean ajaxSingle = Boolean.TRUE.equals(componentAttributes
- .get(AJAX_SINGLE_ATTR));
- // For input components in single mode or without form submit input
- // control )
- if (ajaxSingle && input) { // || action
- // TODO - inside form, put reference :
- // document.forms['form'].controls['control']
- options.put("control", JSReference.THIS);
- }
- // Control value for submit
- String controlName;
- Object controlValue;
- // TODO - make compatible with JSF RI/MyFaces ? use submittedValue ( if
- // any ) for UIInput, converted value for ValueHolder.
- controlName = clientId;
- controlValue = clientId;
- parameters.put(controlName, controlValue);
- if (ajaxSingle) {
- options.put("single", JSReference.TRUE);
- }
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
- // Setup action URL. For portlet environment, it will be different from
- // page.
- options.put("actionUrl", ajaxContext.getAjaxActionURL(facesContext));
- // Add application-wide Ajax parameters
- parameters.putAll(ajaxContext.getCommonAjaxParameters());
- // add child parameters
- for (Iterator it = uiComponent.getChildren().iterator(); it.hasNext();) {
- UIComponent child = (UIComponent) it.next();
- if (child instanceof UIParameter) {
- String name = ((UIParameter) child).getName();
- Object value = ((UIParameter) child).getValue();
- if (null == name) {
- throw new IllegalArgumentException(Messages.getMessage(
- Messages.UNNAMED_PARAMETER_ERROR, uiComponent
- .getClientId(facesContext)));
- }
- boolean escape = true;
- if (child instanceof JavaScriptParameter) {
- JavaScriptParameter actionParam = (JavaScriptParameter) child;
- escape = !actionParam.isNoEscape();
- }
- if (escape) {
- parameters.put(name, value);
- } else {
- parameters.put(name, new JSReference(value.toString()));
- // if(it.hasNext()){onEvent.append(',');};
- // renderAjaxLinkParameter( name,
- // value, onClick, jsForm, nestingForm);
- }
- }
- }
- if (!parameters.isEmpty()) {
- options.put("parameters", parameters);
- }
- // parameter to render only current list of areas.
- if (isAjaxLimitToList(uiComponent)) {
- Set ajaxAreas = getAjaxAreas(uiComponent);
- Set areasIds = new HashSet();
- if (null != ajaxAreas) {
- for (Iterator iter = ajaxAreas.iterator(); iter.hasNext();) {
- String id = (String) iter.next();
- UIComponent comp = uiComponent.findComponent(id);
- if (null != comp) {
- areasIds.add(comp.getClientId(facesContext));
- } else {
- areasIds.add(id);
- }
- }
- }
- options.put("affected", areasIds);
- }
- String oncomplete = getAjaxOncomplete(uiComponent);
- if (null != oncomplete) {
- JSFunctionDefinition function = new JSFunctionDefinition();
- function.addParameter("request");
- function.addParameter("event");
- function.addParameter("data");
- function.addToBody(oncomplete);
-
- options.put("oncomplete", function);
- }
- String status = getAjaxStatus(uiComponent);
- if (null != status) {
- options.put("status", status);
- }
- String queue = (String) componentAttributes.get(AJAX_QUEUE_ATTR);
- Integer requestDelay = (Integer) componentAttributes
- .get(AJAX_DELAY_ATTR);
- if (null != requestDelay && requestDelay.intValue() > 0) {
- options.put(AJAX_DELAY_ATTR, requestDelay);
- if (null == queue) {
- queue = clientId;
- }
- }
- Boolean ignoreDupResponses = (Boolean) componentAttributes
- .get(AJAX_ABORT_ATTR);
- if (null != ignoreDupResponses && ignoreDupResponses.booleanValue()) {
- options.put(AJAX_ABORT_ATTR, JSReference.TRUE);
- if (null == queue) {
- queue = clientId;
- }
- }
- if (null != queue) {
- options.put(AJAX_QUEUE_ATTR, queue);
- }
- // request timeout.
- Integer timeout = (Integer) componentAttributes.get("timeout");
- if (null != timeout && timeout.intValue() > 0) {
- options.put("timeout", timeout);
- }
- // Encoding for requests
- String encoding = (String) componentAttributes.get("encoding");
- if (null != encoding) {
- options.put("encoding", encoding);
- }
- return options;
- }
-
- /**
- * Create call to Ajax Submit function with first two parameters
- *
- * @param uiComponent
- * @param facesContext
- * @param functionName
- * TODO
- * @return
- */
- public static JSFunction buildAjaxFunction(UIComponent uiComponent,
- FacesContext facesContext) {
- JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext,
- AJAX_FUNCTION_NAME);
- // client-side script must have reference to event-enabled object.
- ajaxFunction.addParameter(new JSReference("event"));
- return ajaxFunction;
- }
-
- /**
- * Create call to Ajax Submit function with first two parameters
- *
- * @param uiComponent
- * @param facesContext
- * @param functionName
- * TODO
- * @return
- */
- public static JSFunction buildAjaxFunction(UIComponent uiComponent,
- FacesContext facesContext, String functionName) {
- JSFunction ajaxFunction = new JSFunction(functionName);
- UIComponent nestingContainer = (UIComponent) findAjaxContainer(
- facesContext, uiComponent);
- ajaxFunction.addParameter(nestingContainer.getClientId(facesContext));
- // build form name or ActionUrl for script
- UIComponent nestingForm = getNestingForm(uiComponent);
- if (null == nestingForm) {
- ajaxFunction.addParameter(JSReference.NULL);
- } else {
- ajaxFunction.addParameter(nestingForm.getClientId(facesContext));
- }
- return ajaxFunction;
- }
-
- /**
- * Append common parameters ( array of affected areas, status area id, on
- * complete function ) to JavaScript event string.
- *
- * @param uiComponent
- * @param onClick -
- * buffer with JavaScript code eg... AJAX.Submit(form,this
- */
- // public static void appendAjaxSubmitParameters(FacesContext facesContext,
- // UIComponent uiComponent, StringBuffer onClick)
- // {
- // Set ajaxAreas = getAjaxAreas(uiComponent);
- // onClick.append(',');
- // // parameter to render only current list of areas.
- // if (isAjaxLimitToList(uiComponent) && ajaxAreas != null &&
- // ajaxAreas.size() > 0)
- // {
- // onClick.append('[');
- // Iterator areas = ajaxAreas.iterator();
- // boolean first = true;
- // while (areas.hasNext())
- // {
- // String element = (String) areas.next();
- // UIComponent component = uiComponent.findComponent(element);
- // if (null != component)
- // {
- // if (!first)
- // {
- // onClick.append(',');
- // }
- // else
- // {
- // first = false;
- // }
- // onClick.append('\'');
- // onClick.append(component.getClientId(facesContext));
- // onClick.append('\'');
- // }
- // }
- // onClick.append("]");
- // }
- // else
- // {
- // onClick.append("null");
- // }
- // // insert id of request status element.
- // onClick.append(',');
- // String status = getAjaxStatus(uiComponent);
- // if (null != status)
- // {
- // onClick.append('\'').append(status).append('\'');
- // }
- // else
- // {
- // onClick.append("null");
- // }
- // // insert function name for call after completed request
- // onClick.append(',');
- // String oncomplete = getAjaxOncomplete(uiComponent);
- // if (null != oncomplete)
- // {
- // onClick.append(oncomplete);
- // }
- // else
- // {
- // onClick.append("null");
- // }
- //
- // }
- /**
- * Get list of clientId's for given component
- *
- * @param uiComponent
- * @return List of areas Id's , updated by this component.
- */
- public static Set getAjaxAreas(UIComponent uiComponent) {
- Object areas;
- if (uiComponent instanceof AjaxComponent) {
- areas = ((AjaxComponent) uiComponent).getReRender();
-
- } else {
- areas = uiComponent.getAttributes().get(
- AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE);
- }
- return asSet(areas);
- }
-
- /**
- * Convert parameter ( Collection, List, array, String, comma-separated
- * String ) to list of srings. TODO - when move to JDK 5, change to
- * List<String>
- *
- * @param valueToSet -
- * obect for convert to List.
- * @return - list of strings.
- */
- public static Set asSet(Object valueToSet) {
-
- if (null != valueToSet) {
- // Simplest case - set.
- if (valueToSet instanceof Set) {
- return (Set) valueToSet;
- }
- // Other collections.
- else if (valueToSet instanceof Collection) {
- return new HashSet((Collection) valueToSet);
- }
- // Array
- else if (OBJECT_ARRAY_CLASS.isAssignableFrom(valueToSet.getClass())) {
- return new HashSet(Arrays.asList((Object[]) valueToSet));
- }
- // Tokenize string.
- else if (valueToSet instanceof String) {
- String areasString = (String) valueToSet;
- if (areasString.indexOf(",") > 0) {
- return new HashSet(Arrays.asList(areasString.trim().split(
- "(\\s)*,(\\s)*")));
- } else {
- Set areasSet = new HashSet(5);
- areasSet.add(areasString.trim());
- return areasSet;
- }
-
- }
- }
- return null;
- }
-
- /**
- * Get status area Id for given component.
- *
- * @param component
- * @return clientId of status area, or <code>null</code>
- */
- public static String getAjaxStatus(UIComponent component) {
- String statusId;
- if (component instanceof AjaxComponent) {
- statusId = ((AjaxComponent) component).getStatus();
-
- } else {
- statusId = (String) component.getAttributes().get(STATUS_ATTR_NAME);
- }
- if (null != statusId) {
- UIComponent status = null;
- UIComponent currentParent = component;
- try {
- // Check the naming container of the current
- // component for component identified by
- // 'forComponent'
- while (currentParent != null) {
- // If the current component is a NamingContainer,
- // see if it contains what we're looking for.
- status = currentParent.findComponent(statusId);
- if (status != null)
- break;
- // if not, start checking further up in the view
- currentParent = currentParent.getParent();
- }
- } catch (Exception e) {
- // ignore - log the warning
- }
- if (null != status) {
- statusId = status
- .getClientId(FacesContext.getCurrentInstance());
- } else {
- log.warn(Messages.getMessage(
- Messages.AJAX_STATUS_COMPONENT_NOT_FOWND_WARNING,
- component.getId()));
- }
- }
- return statusId;
- }
-
- /**
- * Get function name for call on completed ajax request.
- *
- * @param component
- * for wich calculate function name
- * @return name of JavaScript function or <code>null</code>
- */
- public static String getAjaxOncomplete(UIComponent component) {
- if (component instanceof AjaxComponent) {
- return ((AjaxComponent) component).getOncomplete();
-
- }
- return (String) component.getAttributes().get(ONCOMPLETE_ATTR_NAME);
- }
-
- /**
- * Calculate, must be component render only given areas, or all sended from
- * server.
- *
- * @param component
- * @return <code>true</code> if client must render ONLY given areas.
- */
- public static boolean isAjaxLimitToList(UIComponent component) {
- boolean result = false;
- if (component instanceof AjaxComponent) {
- result = ((AjaxComponent) component).isLimitToList();
-
- } else {
- try {
- result = ((Boolean) component.getAttributes().get(
- LIMITTOLIST_ATTR_NAME)).booleanValue();
- } catch (NullPointerException e) {
- // NullPointer - ignore ...
- } catch (ClassCastException e1) {
- // not Boolean - false ...
- }
- }
- return result;
- }
-
- /**
- * Replacement for buggy in MyFaces <code>RendererUtils</code>
- *
- * @param component
- * @return
- */
- public static String getAbsoluteId(UIComponent component) {
- if (component == null)
- throw new NullPointerException(Messages
- .getMessage(Messages.COMPONENT_NULL_ERROR_2));
-
- StringBuffer idBuf = new StringBuffer();
-
- idBuf.append(component.getId());
-
- UIComponent parent = component;
-
- while ((parent = parent.getParent()) != null) {
- if (parent instanceof NamingContainer) {
- idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
- idBuf.insert(0, parent.getId());
- }
- }
- idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
- log.debug(Messages.getMessage(Messages.CALCULATE_COMPONENT_ID_INFO,
- component.getId(), idBuf.toString()));
- return idBuf.toString();
- }
-
- /**
- * Find nested form for given component
- *
- * @param component
- * @return nested <code>UIForm</code> component, or
<code>null</code>
- */
- public static UIComponent getNestingForm(UIComponent component) {
- UIComponent parent = component;
- // Search enclosed UIForm or ADF UIXForm component
- while (parent != null
- && !(parent instanceof UIForm)
- && !("org.apache.myfaces.trinidad.Form".equals(parent
- .getFamily()))
- && !("oracle.adf.Form".equals(parent.getFamily()))) {
- parent = parent.getParent();
- }
-
- return parent;
- }
-
- protected static String getAjaxActionUrl(FacesContext facesContext) {
- return
AjaxContext.getCurrentInstance(facesContext).getAjaxActionURL(facesContext);
- }
-
- /**
- * @param facesContext
- * @param uiComponent
- * @return
- */
- public static org.ajax4jsf.framework.ajax.AjaxContainer findAjaxContainer(
- FacesContext facesContext, UIComponent uiComponent) {
- UIComponent parent = uiComponent.getParent();
- while (parent != null
- && !(parent instanceof org.ajax4jsf.framework.ajax.AjaxContainer)) {
- parent = parent.getParent();
- }
-
- org.ajax4jsf.framework.ajax.AjaxContainer nestingContainer = null;
- if (parent != null) {
- // link is nested inside a form
- nestingContainer = (org.ajax4jsf.framework.ajax.AjaxContainer) parent;
- } else if (facesContext.getViewRoot() instanceof AjaxViewRoot) {
- nestingContainer = (AjaxContainer) facesContext.getViewRoot();
- }
- return nestingContainer;
- }
-
- /**
- * For Myfaces, get current viev sequence.
- *
- * @param facescontext
- * @return
- */
- private static Integer getViewSequence(FacesContext facescontext) {
- Map map = facescontext.getExternalContext().getRequestMap();
- Integer sequence = (Integer) map.get(SEQUENCE_PARAM);
- if (sequence == null) {
- sequence = new Integer(1);
- map.put(SEQUENCE_PARAM, sequence);
- }
- return sequence;
- }
-
- /**
- * Encode rendered areas as special HTML tag ( span in current release )
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public static void encodeAreas(FacesContext context,
- UIComponent component) throws IOException {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- ExternalContext externalContext = context.getExternalContext();
- Map requestMap = externalContext.getRequestMap();
- Set rendered = ajaxContext.getAjaxRenderedAreas();
- StringBuffer senderString = new StringBuffer();
- // write special area for list of rendered elements. Client-side
- // Java
- // Script
- // read this structure for update areas of DOM tree.
- ResponseWriter out = context.getResponseWriter();
- // Create <span> element to keep list rendered aread ( in title
- // attribute )
- // More right will create special namespace for such
- // information,
- // but I want to keep simple html ( xhtml ) document - on case
- // I have troubles with microsoft XMLHTTP validations.
- out
- .startElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG,
- component);
- out.writeAttribute(HTML.NAME_ATTRIBUTE,
- AjaxContainerRenderer.AJAX_UPDATE_HEADER, null);
- for (Iterator it = rendered.iterator(); it.hasNext();) {
- String id = (String) it.next();
- // out.startElement(AJAX_RESULT_TAG, component);
- // out.writeText(id,null);
- // out.endElement(AJAX_RESULT_TAG);
- senderString.append(id);
- if (it.hasNext()) {
- senderString.append(',');
- }
- }
- out.writeAttribute(AjaxContainerRenderer.AJAX_RESULT_GROUP_ATTR,
- senderString, null);
- out.endElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG);
- // For sequences and client-saved states.
-
- out.startElement(AjaxContainerRenderer.AJAX_VIEW_STATE_TAG, component);
- out.writeAttribute(HTML.id_ATTRIBUTE,
- AjaxContainerRenderer.AJAX_VIEW_STATE_ID, null);
- writeState(context);
- out.endElement(AjaxContainerRenderer.AJAX_VIEW_STATE_TAG);
- // Write rendered flag to html <meta>
- out
- .startElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG,
- component);
- out.writeAttribute(HTML.id_ATTRIBUTE,
- AjaxContainerRenderer.AJAX_FLAG_HEADER, null);
- out.writeAttribute(HTML.NAME_ATTRIBUTE,
- AjaxContainerRenderer.AJAX_FLAG_HEADER, null);
- out.writeAttribute(AjaxContainerRenderer.AJAX_RESULT_GROUP_ATTR,
- "true", null);
- out.endElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG);
- // set response header with list of rendered ID's
- Object response = externalContext.getResponse();
- // Use reflection for send responce headers - we can get
- // different responces classes
- // for different environment ( portal, cocoon etc )
- if (response instanceof HttpServletResponse) {
- HttpServletResponse httpResponse = (HttpServletResponse) response;
- httpResponse.setHeader(AjaxContainerRenderer.AJAX_UPDATE_HEADER,
- senderString.toString());
- httpResponse.setHeader(AjaxContainerRenderer.AJAX_FLAG_HEADER,
- "true");
- } else {
- try {
- Method setHeadergMethod = response.getClass()
- .getMethod("setHeader",
- new Class[] { String.class, String.class });
- setHeadergMethod.invoke(response, new Object[] {
- AjaxContainerRenderer.AJAX_UPDATE_HEADER,
- senderString.toString() });
- setHeadergMethod.invoke(response, new Object[] {
- AjaxContainerRenderer.AJAX_FLAG_HEADER, "true" });
- } catch (Exception e) {
- log
- .error(Messages
- .getMessage(Messages.DETECTING_ENCODING_DISABLED_ERROR));
- log.error(Messages.getMessage(
- Messages.OBTAIN_RESPONSE_SET_HEADER_ERROR, e));
- }
- }
- Map responseDataMap = ajaxContext.getResponseDataMap();
- // Get data serializer instance
- AJAXDataSerializer serializer = (AJAXDataSerializer) ServicesUtils
- .getServiceInstance(AJAXDataSerializer.SERVICE);
- // Put data to JavaScript handlers, inside <span> elements.
- for (Iterator dataIterator = responseDataMap.keySet().iterator(); dataIterator
- .hasNext();) {
- Object dataKey = dataIterator.next();
- out.startElement(HTML.SPAN_ELEM, component);
- out.writeAttribute(HTML.id_ATTRIBUTE, dataKey, null);
- String dataString = serializer.asString(responseDataMap
- .get(dataKey));
- out.write(dataString);
- out.endElement(HTML.SPAN_ELEM);
- }
- // For self-rendered case, we use own methods for replace stateKey by
- // real value
- // in XML filter.
- // if(ajaxContext.isSelfRender()){
- // saveViewState(context, out);
- // }
- requestMap.put(AJAX_AREAS_RENDERED, "true");
- }
-
- /**
- * Write state saving markers to context, include MyFaces view sequence.
- *
- * @param context
- * @throws IOException
- */
- public static void writeState(FacesContext context) throws IOException {
- if (!context.getApplication().getStateManager().isSavingStateInClient(
- context)) {
- ResponseWriter writer = context.getResponseWriter();
- // MyFaces-specific view sequence attribute
- writer.startElement(HTML.INPUT_ELEM, null);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE,
- AjaxRendererUtils.SEQUENCE_PARAM, null);
- writer.writeAttribute(HTML.value_ATTRIBUTE, AjaxRendererUtils
- .getViewSequence(context), null);
- writer.endElement(HTML.INPUT_ELEM);
- }
- context.getApplication().getViewHandler().writeState(context);
- }
-
- /**
- * Encode declaration for AJAX response. Render
<html><body>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public static void encodeAjaxBegin(FacesContext context,
- UIComponent component) throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
- out.startElement("html", component);
- // TODO - html attributes. lang - from current locale ?
- Locale locale = context.getViewRoot().getLocale();
- out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
- out.startElement("body", component);
- }
-
- /**
- * End encoding of AJAX response. Render tag with included areas and close
- * </body></html>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public static void encodeAjaxEnd(FacesContext context, UIComponent component)
- throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
-
- encodeAreas(context, component);
- out.endElement("body");
- out.endElement("html");
- }
-
- /**
- * Find all instances of {@link UILoadBundle} in view tree and load bundles
- * to request-scope map.
- *
- * @param context
- * @throws IOException
- */
- public static void loadBundles(FacesContext context) {
- // TODO - performanse improove - don't seek by all components tree.
- loadBundles(context, context.getViewRoot());
-
- }
-
- /**
- * Recursive helper for {@link #loadBundles(FacesContext)}
- *
- * @param context
- * @param component
- * @throws IOException
- */
- private static void loadBundles(FacesContext context, UIComponent component) {
- // Iterate over cildrens
- for (Iterator iter = component.getChildren().iterator(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- loadCildBundles(context, child);
- }
- // Iterate over facets
- for (Iterator iter = component.getFacets().values().iterator(); iter
- .hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- loadCildBundles(context, child);
- }
- }
-
- /**
- * @param context
- * @param child
- */
- private static void loadCildBundles(FacesContext context, UIComponent child) {
- if (child instanceof UILoadBundle) {
- try {
- child.encodeBegin(context);
- } catch (IOException e) {
- // DO nothing - really, LoadBundle don't can throw exceptions.
- }
- } else {
- loadBundles(context, child);
- }
- }
-
- /**
- * @param facesContext
- * @return
- */
- public static boolean isAjaxRequest(FacesContext facesContext) {
-
- return AjaxContext.getCurrentInstance(facesContext).isAjaxRequest(facesContext);
- }
-
- /**
- * @param facesContext
- * @param component
- * @param id
- */
- public static void addRegionByName(FacesContext facesContext, UIComponent component,
String id) {
-
- AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(component, id);
- }
- /**
- * @param facesContext
- * @param component
- * @param id
- */
- public static void addRegionsFromComponent(UIComponent component, FacesContext
facesContext) {
-
- AjaxContext.getCurrentInstance(facesContext).addRegionsFromComponent(component);
- }
-
-}
Copied:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
(from rev 164,
trunk/framework/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java)
===================================================================
---
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,936 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.renderer;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.application.ViewHandler;
+import javax.faces.component.ActionSource;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIParameter;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.ajax.UILoadBundle;
+import org.ajax4jsf.framework.ajax.AjaxComponent;
+import org.ajax4jsf.framework.ajax.AjaxContainer;
+import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxSupport;
+import org.ajax4jsf.framework.ajax.AjaxViewRoot;
+import org.ajax4jsf.framework.ajax.JavaScriptParameter;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.util.ServicesUtils;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
+import org.ajax4jsf.framework.util.javascript.JSReference;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura
+ *
+ * Some utilites for render AJAX components.
+ */
+public class AjaxRendererUtils {
+
+ /**
+ * Name Javasript function for submit AJAX request
+ */
+ public static final String AJAX_FUNCTION_NAME = "A4J.AJAX.Submit";
+
+ /**
+ * Attribute for keep clientId of status component
+ */
+ public static final String STATUS_ATTR_NAME = "status";
+
+ /**
+ * Attribute for keep JavaScript funtion name for call after complete
+ * request.
+ */
+ public static final String ONCOMPLETE_ATTR_NAME = "oncomplete";
+
+ /**
+ * Attribute to keep
+ */
+ public static final String LIMITTOLIST_ATTR_NAME = "limitToList";
+
+ private static Log log = LogFactory.getLog(AjaxRendererUtils.class);
+
+ public static final String AJAX_REGIONS_ATTRIBUTE = "reRender";
+
+ private static final Class OBJECT_ARRAY_CLASS = (new Object[0]).getClass();
+
+ public static final String SEQUENCE_PARAM = "jsf_sequence";
+
+ private static final String VALUE_ATTR = "value";
+
+ public static final String AJAX_AREAS_RENDERED =
"org.ajax4jsf.areas.rendered";
+
+ private static final String AJAX_SINGLE_ATTR = "ajaxSingle";
+
+ public static final String AJAX_QUEUE_ATTR = "eventsQueue";
+
+ public static final String AJAX_DELAY_ATTR = "requestDelay";
+
+ private static final Object AJAX_ABORT_ATTR = "ignoreDupResponses";
+
+ /**
+ * Static class - protect constructor TODO - make as subclass of chameleon
+ * RendererUtils.
+ *
+ */
+ private AjaxRendererUtils() {
+
+ }
+
+ /**
+ * Build JavaScript onclick event for given component
+ *
+ * @param uiComponent -
+ * component for build event
+ * @param facesContext
+ * @return <code>StringBuffer</code> with Javascript code
+ */
+ public static StringBuffer buildOnClick(UIComponent uiComponent,
+ FacesContext facesContext) {
+ return buildOnEvent(uiComponent, facesContext, HTML.onclick_ATTRIBUTE);
+ }
+
+ /**
+ * Build JavaScript event for component
+ *
+ * @param uiComponent -
+ * component for build event
+ * @param facesContext
+ * @param eventName -
+ * name of event
+ * @return <code>StringBuffer</code> with Javascript code TODO - for
+ * key-based events build list of supported keys
+ */
+ public static StringBuffer buildOnEvent(UIComponent uiComponent,
+ FacesContext facesContext, String eventName) {
+ StringBuffer onEvent = new StringBuffer();
+ if (null != eventName) {
+ String commandOnEvent = (String) uiComponent.getAttributes().get(
+ eventName);
+ if (commandOnEvent != null) {
+ onEvent.append(commandOnEvent);
+ onEvent.append(';');
+ }
+ }
+ JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext);
+ // Create formal parameter for non-input elements ???
+ // Link Control pseudo-object
+ // Options map. Possible options for function call :
+ // control - name of form control for submit.
+ // name - name for link control \
+ // value - value of control. - possible replace by parameters ?
+ // single true/false - submit all form or only one control.
+ // affected - array of element's ID for update on responce.
+ // oncomplete - function for call after complete request.
+ // status - id of request status component.
+ // parameters - map of parameters name/value for append on request.
+ // TODO
+ // sync true/false - run script in sync mode.
+ // ..........
+ ajaxFunction.addParameter(buildEventOptions(facesContext, uiComponent));
+
+ // appendAjaxSubmitParameters(facesContext, uiComponent, onEvent);
+ ajaxFunction.appendScript(onEvent);
+ if (uiComponent instanceof AjaxSupport) {
+ AjaxSupport support = (AjaxSupport) uiComponent;
+ if (support.isDisableDefault()) {
+ onEvent.append("; return false;");
+ }
+ }
+ log.debug(Messages.getMessage(Messages.BUILD_ONCLICK_INFO, uiComponent
+ .getId(), onEvent.toString()));
+ return onEvent;
+
+ }
+
+ /**
+ * @param facesContext
+ * @param uiComponent
+ * @return
+ */
+ public static Map buildEventOptions(FacesContext facesContext,
+ UIComponent uiComponent) {
+ String clientId = uiComponent.getClientId(facesContext);
+ Map componentAttributes = uiComponent.getAttributes();
+ Map options = new HashMap();
+ Map parameters = new HashMap();
+ // UIForm form = getNestingForm(uiComponent);
+ // "input" - if assigned to html input element.
+ boolean input = (uiComponent instanceof AjaxSupport && uiComponent
+ .getParent() instanceof EditableValueHolder)
+ || uiComponent instanceof EditableValueHolder;
+ // Action component - button etc.
+ boolean action = (uiComponent instanceof AjaxSupport && uiComponent
+ .getParent() instanceof ActionSource)
+ || uiComponent instanceof ActionSource;
+ // TODO - disable ( or not ? ) submission of action for disabled default
+ // ?
+ // if ( action && uiComponent instanceof AjaxSupport) {
+ // AjaxSupport support = (AjaxSupport) uiComponent;
+ // if (support.isDisableDefault()) {
+ // action = false;
+ // }
+ // }
+
+ boolean ajaxSingle = Boolean.TRUE.equals(componentAttributes
+ .get(AJAX_SINGLE_ATTR));
+ // For input components in single mode or without form submit input
+ // control )
+ if (ajaxSingle && input) { // || action
+ // TODO - inside form, put reference :
+ // document.forms['form'].controls['control']
+ options.put("control", JSReference.THIS);
+ }
+ // Control value for submit
+ String controlName;
+ Object controlValue;
+ // TODO - make compatible with JSF RI/MyFaces ? use submittedValue ( if
+ // any ) for UIInput, converted value for ValueHolder.
+ controlName = clientId;
+ controlValue = clientId;
+ parameters.put(controlName, controlValue);
+ // Move processing of a 'single' attribute to a server-side.
+// if (ajaxSingle) {
+// options.put("single", JSReference.TRUE);
+// }
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
+ // Setup action URL. For portlet environment, it will be different from
+ // page.
+ options.put("actionUrl", ajaxContext.getAjaxActionURL(facesContext));
+ // Add application-wide Ajax parameters
+ parameters.putAll(ajaxContext.getCommonAjaxParameters());
+ // add child parameters
+ for (Iterator it = uiComponent.getChildren().iterator(); it.hasNext();) {
+ UIComponent child = (UIComponent) it.next();
+ if (child instanceof UIParameter) {
+ String name = ((UIParameter) child).getName();
+ Object value = ((UIParameter) child).getValue();
+ if (null == name) {
+ throw new IllegalArgumentException(Messages.getMessage(
+ Messages.UNNAMED_PARAMETER_ERROR, uiComponent
+ .getClientId(facesContext)));
+ }
+ boolean escape = true;
+ if (child instanceof JavaScriptParameter) {
+ JavaScriptParameter actionParam = (JavaScriptParameter) child;
+ escape = !actionParam.isNoEscape();
+ }
+ if (escape) {
+ parameters.put(name, value);
+ } else {
+ parameters.put(name, new JSReference(value.toString()));
+ // if(it.hasNext()){onEvent.append(',');};
+ // renderAjaxLinkParameter( name,
+ // value, onClick, jsForm, nestingForm);
+ }
+ }
+ }
+ if (!parameters.isEmpty()) {
+ options.put("parameters", parameters);
+ }
+ // parameter to render only current list of areas.
+ if (isAjaxLimitToList(uiComponent)) {
+ Set ajaxAreas = getAjaxAreas(uiComponent);
+ Set areasIds = new HashSet();
+ if (null != ajaxAreas) {
+ for (Iterator iter = ajaxAreas.iterator(); iter.hasNext();) {
+ String id = (String) iter.next();
+ UIComponent comp = uiComponent.findComponent(id);
+ if (null != comp) {
+ areasIds.add(comp.getClientId(facesContext));
+ } else {
+ areasIds.add(id);
+ }
+ }
+ }
+ options.put("affected", areasIds);
+ }
+ String oncomplete = getAjaxOncomplete(uiComponent);
+ if (null != oncomplete) {
+ JSFunctionDefinition function = new JSFunctionDefinition();
+ function.addParameter("request");
+ function.addParameter("event");
+ function.addParameter("data");
+ function.addToBody(oncomplete);
+
+ options.put("oncomplete", function);
+ }
+ String status = getAjaxStatus(uiComponent);
+ if (null != status) {
+ options.put("status", status);
+ }
+ String queue = (String) componentAttributes.get(AJAX_QUEUE_ATTR);
+ Integer requestDelay = (Integer) componentAttributes
+ .get(AJAX_DELAY_ATTR);
+ if (null != requestDelay && requestDelay.intValue() > 0) {
+ options.put(AJAX_DELAY_ATTR, requestDelay);
+ if (null == queue) {
+ queue = clientId;
+ }
+ }
+ Boolean ignoreDupResponses = (Boolean) componentAttributes
+ .get(AJAX_ABORT_ATTR);
+ if (null != ignoreDupResponses && ignoreDupResponses.booleanValue()) {
+ options.put(AJAX_ABORT_ATTR, JSReference.TRUE);
+ if (null == queue) {
+ queue = clientId;
+ }
+ }
+ if (null != queue) {
+ options.put(AJAX_QUEUE_ATTR, queue);
+ }
+ // request timeout.
+ Integer timeout = (Integer) componentAttributes.get("timeout");
+ if (null != timeout && timeout.intValue() > 0) {
+ options.put("timeout", timeout);
+ }
+ // Encoding for requests
+ String encoding = (String) componentAttributes.get("encoding");
+ if (null != encoding) {
+ options.put("encoding", encoding);
+ }
+ return options;
+ }
+
+ /**
+ * Create call to Ajax Submit function with first two parameters
+ *
+ * @param uiComponent
+ * @param facesContext
+ * @param functionName
+ * TODO
+ * @return
+ */
+ public static JSFunction buildAjaxFunction(UIComponent uiComponent,
+ FacesContext facesContext) {
+ JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext,
+ AJAX_FUNCTION_NAME);
+ // client-side script must have reference to event-enabled object.
+ ajaxFunction.addParameter(new JSReference("event"));
+ return ajaxFunction;
+ }
+
+ /**
+ * Create call to Ajax Submit function with first two parameters
+ *
+ * @param uiComponent
+ * @param facesContext
+ * @param functionName
+ * TODO
+ * @return
+ */
+ public static JSFunction buildAjaxFunction(UIComponent uiComponent,
+ FacesContext facesContext, String functionName) {
+ JSFunction ajaxFunction = new JSFunction(functionName);
+ UIComponent nestingContainer = (UIComponent) findAjaxContainer(
+ facesContext, uiComponent);
+ ajaxFunction.addParameter(nestingContainer.getClientId(facesContext));
+ // build form name or ActionUrl for script
+ UIComponent nestingForm = getNestingForm(uiComponent);
+ if (null == nestingForm) {
+ ajaxFunction.addParameter(JSReference.NULL);
+ } else {
+ ajaxFunction.addParameter(nestingForm.getClientId(facesContext));
+ }
+ return ajaxFunction;
+ }
+
+ /**
+ * Append common parameters ( array of affected areas, status area id, on
+ * complete function ) to JavaScript event string.
+ *
+ * @param uiComponent
+ * @param onClick -
+ * buffer with JavaScript code eg... AJAX.Submit(form,this
+ */
+ // public static void appendAjaxSubmitParameters(FacesContext facesContext,
+ // UIComponent uiComponent, StringBuffer onClick)
+ // {
+ // Set ajaxAreas = getAjaxAreas(uiComponent);
+ // onClick.append(',');
+ // // parameter to render only current list of areas.
+ // if (isAjaxLimitToList(uiComponent) && ajaxAreas != null &&
+ // ajaxAreas.size() > 0)
+ // {
+ // onClick.append('[');
+ // Iterator areas = ajaxAreas.iterator();
+ // boolean first = true;
+ // while (areas.hasNext())
+ // {
+ // String element = (String) areas.next();
+ // UIComponent component = uiComponent.findComponent(element);
+ // if (null != component)
+ // {
+ // if (!first)
+ // {
+ // onClick.append(',');
+ // }
+ // else
+ // {
+ // first = false;
+ // }
+ // onClick.append('\'');
+ // onClick.append(component.getClientId(facesContext));
+ // onClick.append('\'');
+ // }
+ // }
+ // onClick.append("]");
+ // }
+ // else
+ // {
+ // onClick.append("null");
+ // }
+ // // insert id of request status element.
+ // onClick.append(',');
+ // String status = getAjaxStatus(uiComponent);
+ // if (null != status)
+ // {
+ // onClick.append('\'').append(status).append('\'');
+ // }
+ // else
+ // {
+ // onClick.append("null");
+ // }
+ // // insert function name for call after completed request
+ // onClick.append(',');
+ // String oncomplete = getAjaxOncomplete(uiComponent);
+ // if (null != oncomplete)
+ // {
+ // onClick.append(oncomplete);
+ // }
+ // else
+ // {
+ // onClick.append("null");
+ // }
+ //
+ // }
+ /**
+ * Get list of clientId's for given component
+ *
+ * @param uiComponent
+ * @return List of areas Id's , updated by this component.
+ */
+ public static Set getAjaxAreas(UIComponent uiComponent) {
+ Object areas;
+ if (uiComponent instanceof AjaxComponent) {
+ areas = ((AjaxComponent) uiComponent).getReRender();
+
+ } else {
+ areas = uiComponent.getAttributes().get(
+ AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE);
+ }
+ return asSet(areas);
+ }
+
+ /**
+ * Convert parameter ( Collection, List, array, String, comma-separated
+ * String ) to list of srings. TODO - when move to JDK 5, change to
+ * List<String>
+ *
+ * @param valueToSet -
+ * obect for convert to List.
+ * @return - list of strings.
+ */
+ public static Set asSet(Object valueToSet) {
+
+ if (null != valueToSet) {
+ // Simplest case - set.
+ if (valueToSet instanceof Set) {
+ return (Set) valueToSet;
+ }
+ // Other collections.
+ else if (valueToSet instanceof Collection) {
+ return new HashSet((Collection) valueToSet);
+ }
+ // Array
+ else if (OBJECT_ARRAY_CLASS.isAssignableFrom(valueToSet.getClass())) {
+ return new HashSet(Arrays.asList((Object[]) valueToSet));
+ }
+ // Tokenize string.
+ else if (valueToSet instanceof String) {
+ String areasString = (String) valueToSet;
+ if (areasString.indexOf(",") > 0) {
+ return new HashSet(Arrays.asList(areasString.trim().split(
+ "(\\s)*,(\\s)*")));
+ } else {
+ Set areasSet = new HashSet(5);
+ areasSet.add(areasString.trim());
+ return areasSet;
+ }
+
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get status area Id for given component.
+ *
+ * @param component
+ * @return clientId of status area, or <code>null</code>
+ */
+ public static String getAjaxStatus(UIComponent component) {
+ String statusId;
+ if (component instanceof AjaxComponent) {
+ statusId = ((AjaxComponent) component).getStatus();
+
+ } else {
+ statusId = (String) component.getAttributes().get(STATUS_ATTR_NAME);
+ }
+ if (null != statusId) {
+ UIComponent status = null;
+ UIComponent currentParent = component;
+ try {
+ // Check the naming container of the current
+ // component for component identified by
+ // 'forComponent'
+ while (currentParent != null) {
+ // If the current component is a NamingContainer,
+ // see if it contains what we're looking for.
+ status = currentParent.findComponent(statusId);
+ if (status != null)
+ break;
+ // if not, start checking further up in the view
+ currentParent = currentParent.getParent();
+ }
+ } catch (Exception e) {
+ // ignore - log the warning
+ }
+ if (null != status) {
+ statusId = status
+ .getClientId(FacesContext.getCurrentInstance());
+ } else {
+ log.warn(Messages.getMessage(
+ Messages.AJAX_STATUS_COMPONENT_NOT_FOWND_WARNING,
+ component.getId()));
+ }
+ }
+ return statusId;
+ }
+
+ /**
+ * Get function name for call on completed ajax request.
+ *
+ * @param component
+ * for wich calculate function name
+ * @return name of JavaScript function or <code>null</code>
+ */
+ public static String getAjaxOncomplete(UIComponent component) {
+ if (component instanceof AjaxComponent) {
+ return ((AjaxComponent) component).getOncomplete();
+
+ }
+ return (String) component.getAttributes().get(ONCOMPLETE_ATTR_NAME);
+ }
+
+ /**
+ * Calculate, must be component render only given areas, or all sended from
+ * server.
+ *
+ * @param component
+ * @return <code>true</code> if client must render ONLY given areas.
+ */
+ public static boolean isAjaxLimitToList(UIComponent component) {
+ boolean result = false;
+ if (component instanceof AjaxComponent) {
+ result = ((AjaxComponent) component).isLimitToList();
+
+ } else {
+ try {
+ result = ((Boolean) component.getAttributes().get(
+ LIMITTOLIST_ATTR_NAME)).booleanValue();
+ } catch (NullPointerException e) {
+ // NullPointer - ignore ...
+ } catch (ClassCastException e1) {
+ // not Boolean - false ...
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Replacement for buggy in MyFaces <code>RendererUtils</code>
+ *
+ * @param component
+ * @return
+ */
+ public static String getAbsoluteId(UIComponent component) {
+ if (component == null)
+ throw new NullPointerException(Messages
+ .getMessage(Messages.COMPONENT_NULL_ERROR_2));
+
+ StringBuffer idBuf = new StringBuffer();
+
+ idBuf.append(component.getId());
+
+ UIComponent parent = component;
+
+ while ((parent = parent.getParent()) != null) {
+ if (parent instanceof NamingContainer) {
+ idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
+ idBuf.insert(0, parent.getId());
+ }
+ }
+ idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
+ log.debug(Messages.getMessage(Messages.CALCULATE_COMPONENT_ID_INFO,
+ component.getId(), idBuf.toString()));
+ return idBuf.toString();
+ }
+
+ /**
+ * Find nested form for given component
+ *
+ * @param component
+ * @return nested <code>UIForm</code> component, or
<code>null</code>
+ */
+ public static UIComponent getNestingForm(UIComponent component) {
+ UIComponent parent = component;
+ // Search enclosed UIForm or ADF UIXForm component
+ while (parent != null
+ && !(parent instanceof UIForm)
+ && !("org.apache.myfaces.trinidad.Form".equals(parent
+ .getFamily()))
+ && !("oracle.adf.Form".equals(parent.getFamily()))) {
+ parent = parent.getParent();
+ }
+
+ return parent;
+ }
+
+ protected static String getAjaxActionUrl(FacesContext facesContext) {
+ return
AjaxContext.getCurrentInstance(facesContext).getAjaxActionURL(facesContext);
+ }
+
+ /**
+ * @param facesContext
+ * @param uiComponent
+ * @return
+ */
+ public static org.ajax4jsf.framework.ajax.AjaxContainer findAjaxContainer(
+ FacesContext facesContext, UIComponent uiComponent) {
+ UIComponent parent = uiComponent.getParent();
+ while (parent != null
+ && !(parent instanceof org.ajax4jsf.framework.ajax.AjaxContainer)) {
+ parent = parent.getParent();
+ }
+
+ org.ajax4jsf.framework.ajax.AjaxContainer nestingContainer = null;
+ if (parent != null) {
+ // link is nested inside a form
+ nestingContainer = (org.ajax4jsf.framework.ajax.AjaxContainer) parent;
+ } else if (facesContext.getViewRoot() instanceof AjaxViewRoot) {
+ nestingContainer = (AjaxContainer) facesContext.getViewRoot();
+ }
+ return nestingContainer;
+ }
+
+ /**
+ * For Myfaces, get current viev sequence.
+ *
+ * @param facescontext
+ * @return
+ */
+ private static Integer getViewSequence(FacesContext facescontext) {
+ Map map = facescontext.getExternalContext().getRequestMap();
+ Integer sequence = (Integer) map.get(SEQUENCE_PARAM);
+ if (sequence == null) {
+ sequence = new Integer(1);
+ map.put(SEQUENCE_PARAM, sequence);
+ }
+ return sequence;
+ }
+
+ /**
+ * Encode rendered areas as special HTML tag ( span in current release )
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public static void encodeAreas(FacesContext context,
+ UIComponent component) throws IOException {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ExternalContext externalContext = context.getExternalContext();
+ Map requestMap = externalContext.getRequestMap();
+ Set rendered = ajaxContext.getAjaxRenderedAreas();
+ StringBuffer senderString = new StringBuffer();
+ // write special area for list of rendered elements. Client-side
+ // Java
+ // Script
+ // read this structure for update areas of DOM tree.
+ ResponseWriter out = context.getResponseWriter();
+ // Create <span> element to keep list rendered aread ( in title
+ // attribute )
+ // More right will create special namespace for such
+ // information,
+ // but I want to keep simple html ( xhtml ) document - on case
+ // I have troubles with microsoft XMLHTTP validations.
+ out
+ .startElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG,
+ component);
+ out.writeAttribute(HTML.NAME_ATTRIBUTE,
+ AjaxContainerRenderer.AJAX_UPDATE_HEADER, null);
+ for (Iterator it = rendered.iterator(); it.hasNext();) {
+ String id = (String) it.next();
+ // out.startElement(AJAX_RESULT_TAG, component);
+ // out.writeText(id,null);
+ // out.endElement(AJAX_RESULT_TAG);
+ senderString.append(id);
+ if (it.hasNext()) {
+ senderString.append(',');
+ }
+ }
+ out.writeAttribute(AjaxContainerRenderer.AJAX_RESULT_GROUP_ATTR,
+ senderString, null);
+ out.endElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG);
+ // For sequences and client-saved states.
+
+ out.startElement(AjaxContainerRenderer.AJAX_VIEW_STATE_TAG, component);
+ out.writeAttribute(HTML.id_ATTRIBUTE,
+ AjaxContainerRenderer.AJAX_VIEW_STATE_ID, null);
+ writeState(context);
+ out.endElement(AjaxContainerRenderer.AJAX_VIEW_STATE_TAG);
+ // Write rendered flag to html <meta>
+ out
+ .startElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG,
+ component);
+ out.writeAttribute(HTML.id_ATTRIBUTE,
+ AjaxContainerRenderer.AJAX_FLAG_HEADER, null);
+ out.writeAttribute(HTML.NAME_ATTRIBUTE,
+ AjaxContainerRenderer.AJAX_FLAG_HEADER, null);
+ out.writeAttribute(AjaxContainerRenderer.AJAX_RESULT_GROUP_ATTR,
+ "true", null);
+ out.endElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG);
+ // set response header with list of rendered ID's
+ Object response = externalContext.getResponse();
+ // Use reflection for send responce headers - we can get
+ // different responces classes
+ // for different environment ( portal, cocoon etc )
+ if (response instanceof HttpServletResponse) {
+ HttpServletResponse httpResponse = (HttpServletResponse) response;
+ httpResponse.setHeader(AjaxContainerRenderer.AJAX_UPDATE_HEADER,
+ senderString.toString());
+ httpResponse.setHeader(AjaxContainerRenderer.AJAX_FLAG_HEADER,
+ "true");
+ } else {
+ try {
+ Method setHeadergMethod = response.getClass()
+ .getMethod("setHeader",
+ new Class[] { String.class, String.class });
+ setHeadergMethod.invoke(response, new Object[] {
+ AjaxContainerRenderer.AJAX_UPDATE_HEADER,
+ senderString.toString() });
+ setHeadergMethod.invoke(response, new Object[] {
+ AjaxContainerRenderer.AJAX_FLAG_HEADER, "true" });
+ } catch (Exception e) {
+ log
+ .error(Messages
+ .getMessage(Messages.DETECTING_ENCODING_DISABLED_ERROR));
+ log.error(Messages.getMessage(
+ Messages.OBTAIN_RESPONSE_SET_HEADER_ERROR, e));
+ }
+ }
+ Map responseDataMap = ajaxContext.getResponseDataMap();
+ // Get data serializer instance
+ AJAXDataSerializer serializer = (AJAXDataSerializer) ServicesUtils
+ .getServiceInstance(AJAXDataSerializer.SERVICE);
+ // Put data to JavaScript handlers, inside <span> elements.
+ for (Iterator dataIterator = responseDataMap.keySet().iterator(); dataIterator
+ .hasNext();) {
+ Object dataKey = dataIterator.next();
+ out.startElement(HTML.SPAN_ELEM, component);
+ out.writeAttribute(HTML.id_ATTRIBUTE, dataKey, null);
+ String dataString = serializer.asString(responseDataMap
+ .get(dataKey));
+ out.write(dataString);
+ out.endElement(HTML.SPAN_ELEM);
+ }
+ // For self-rendered case, we use own methods for replace stateKey by
+ // real value
+ // in XML filter.
+ // if(ajaxContext.isSelfRender()){
+ // saveViewState(context, out);
+ // }
+ requestMap.put(AJAX_AREAS_RENDERED, "true");
+ }
+
+ /**
+ * Write state saving markers to context, include MyFaces view sequence.
+ *
+ * @param context
+ * @throws IOException
+ */
+ public static void writeState(FacesContext context) throws IOException {
+ if (!context.getApplication().getStateManager().isSavingStateInClient(
+ context)) {
+ ResponseWriter writer = context.getResponseWriter();
+ // MyFaces-specific view sequence attribute
+ writer.startElement(HTML.INPUT_ELEM, null);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE,
+ AjaxRendererUtils.SEQUENCE_PARAM, null);
+ writer.writeAttribute(HTML.value_ATTRIBUTE, AjaxRendererUtils
+ .getViewSequence(context), null);
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+ context.getApplication().getViewHandler().writeState(context);
+ }
+
+ /**
+ * Encode declaration for AJAX response. Render
<html><body>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public static void encodeAjaxBegin(FacesContext context,
+ UIComponent component) throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+ out.startElement("html", component);
+ // TODO - html attributes. lang - from current locale ?
+ Locale locale = context.getViewRoot().getLocale();
+ out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
+ out.startElement("body", component);
+ }
+
+ /**
+ * End encoding of AJAX response. Render tag with included areas and close
+ * </body></html>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public static void encodeAjaxEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+
+ encodeAreas(context, component);
+ out.endElement("body");
+ out.endElement("html");
+ }
+
+ /**
+ * Find all instances of {@link UILoadBundle} in view tree and load bundles
+ * to request-scope map.
+ *
+ * @param context
+ * @throws IOException
+ */
+ public static void loadBundles(FacesContext context) {
+ // TODO - performanse improove - don't seek by all components tree.
+ loadBundles(context, context.getViewRoot());
+
+ }
+
+ /**
+ * Recursive helper for {@link #loadBundles(FacesContext)}
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ private static void loadBundles(FacesContext context, UIComponent component) {
+ // Iterate over cildrens
+ for (Iterator iter = component.getChildren().iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ loadCildBundles(context, child);
+ }
+ // Iterate over facets
+ for (Iterator iter = component.getFacets().values().iterator(); iter
+ .hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ loadCildBundles(context, child);
+ }
+ }
+
+ /**
+ * @param context
+ * @param child
+ */
+ private static void loadCildBundles(FacesContext context, UIComponent child) {
+ if (child instanceof UILoadBundle) {
+ try {
+ child.encodeBegin(context);
+ } catch (IOException e) {
+ // DO nothing - really, LoadBundle don't can throw exceptions.
+ }
+ } else {
+ loadBundles(context, child);
+ }
+ }
+
+ /**
+ * @param facesContext
+ * @return
+ */
+ public static boolean isAjaxRequest(FacesContext facesContext) {
+
+ return AjaxContext.getCurrentInstance(facesContext).isAjaxRequest(facesContext);
+ }
+
+ /**
+ * @param facesContext
+ * @param component
+ * @param id
+ */
+ public static void addRegionByName(FacesContext facesContext, UIComponent component,
String id) {
+
+ AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(component, id);
+ }
+ /**
+ * @param facesContext
+ * @param component
+ * @param id
+ */
+ public static void addRegionsFromComponent(UIComponent component, FacesContext
facesContext) {
+
+ AjaxContext.getCurrentInstance(facesContext).addRegionsFromComponent(component);
+ }
+
+}
Copied:
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
(from rev 164,
trunk/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java)
===================================================================
---
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
(rev 0)
+++
tags/1_1_1_rc1/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,118 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.ajax.UIPush;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.RendererUtils;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.javascript.JSReference;
+import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
+
+/**
+ * @author shura
+ *
+ */
+public class AjaxPushRenderer extends AjaxCommandRendererBase {
+
+ public static final String PUSH_INTERVAL_PARAMETER =
"A4J.AJAX.Push.INTERVAL";
+
+ public static final String PUSH_WAIT_PARAMETER = "A4J.AJAX.Push.WAIT";
+
+ public static final String PUSH_URL_PARAMETER = "A4J.AJAX.Push.URL";
+
+ public static final int DEFAULT_PUSH_INTERVAL = 1000;
+
+ public static final int DEFAULT_PUSH_WAIT = Integer.MIN_VALUE;
+
+ private static final String AJAX_PUSH_FUNCTION = "A4J.AJAX.Push";
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+ UIPush push = (UIPush) component;
+ writer.startElement(HTML.SPAN_ELEM, component);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "display:none;", null);
+ getUtils().encodeId(context, component);
+ getUtils().encodeBeginFormIfNessesary(context, component);
+ // pushing script.
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ StringBuffer script = new StringBuffer("\n");
+ if(push.isEnabled()){
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context,
AJAX_PUSH_FUNCTION);
+ // Set dummy form id, if nessesary.
+ Map options = AjaxRendererUtils.buildEventOptions(context, component);
+ options.put("dummyForm",
component.getClientId(context)+RendererUtils.DUMMY_FORM_ID);
+ int interval = push.getInterval();
+ if(interval == Integer.MIN_VALUE){
+ String intervalInitParameter =
context.getExternalContext().getInitParameter(PUSH_INTERVAL_PARAMETER);
+ if(null != intervalInitParameter){
+ interval = Integer.parseInt(intervalInitParameter);
+ } else {
+ interval = DEFAULT_PUSH_INTERVAL;
+ }
+ }
+ options.put("pushinterval", new Integer(interval));
+ options.put("pushId", push.getListenerId(context));
+ String pushUrl = context.getExternalContext().getInitParameter(PUSH_URL_PARAMETER);
+ if(null != pushUrl){
+ options.put("pushUrl", pushUrl);
+ }
+ // options.put("timeout", interval);
+ function.addParameter(options);
+ function.appendScript(script);
+ } else {
+ script.append("A4J.AJAX.StopPush('").append(push.getListenerId(context)).append("')");
+ }
+ script.append(";\n");
+ writer.writeText(script.toString(),null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ getUtils().encodeEndFormIfNessesary(context, component);
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // only push component is allowed.
+ return UIPush.class;
+ }
+
+ protected boolean isSubmitted(FacesContext facesContext, UIComponent uiComponent) {
+ boolean submitted = super.isSubmitted(facesContext, uiComponent);
+ UIPush push = (UIPush) uiComponent;
+ push.setSubmitted(submitted);
+ return submitted;
+ }
+
+}
Deleted: tags/1_1_1_rc1/framework/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-05-02 17:40:09 UTC (rev
158)
+++ tags/1_1_1_rc1/framework/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-05-04 01:10:03
UTC (rev 168)
@@ -1,1103 +0,0 @@
-// Global Variables
-// var timeout = null;
-
-// TODO - use sarissa for standard XMLHttpRequest Support.
-
-
-// AJAX-JSF AJAX-like library, for communicate with view Tree on server side.
-
-// Modified by Alexander J. Smirnov to use as JSF AJAX-like components.
-
-A4J.AJAX = {};
-
-/**
- * XMLHttp transport class - incapsulate most of client-specifiv functions for call
server requests.
- */
-A4J.AJAX.XMLHttpRequest = function(query){
- this._query = query;
- };
-
-A4J.AJAX.XMLHttpRequest.prototype = {
- _query : null,
- _timeout : 0,
- _timeoutID : null,
- onready : null,
- _parsingStatus : Sarissa.PARSED_EMPTY,
- _errorMessage : "XML Response object not set",
- _contentType : null,
- _onerror : function(req,status,message) {
- // Status not 200 - error !!!! TODO - I18N ???
- window.alert(message);
- },
- onfinish : null,
- options : {},
- domEvt : null,
- form : null,
- _request : null,
- _aborted : false,
-
- setRequestTimeout : function(timeout){
- this._timeout = timeout;
- },
- /**
- * Send request to server with parameters from query ( POST or GET depend on client type
)
- */
- send : function(){
- this._request = new XMLHttpRequest();
- var _this = this;
- this._request.onreadystatechange = function(){
- if(_this._aborted){return;};
- LOG.debug("Reqest state : "+_this._request.readyState );
- if (_this._request.readyState == 4 ) {
- LOG.debug("Reqest end with state 4");
- if(_this._timeoutID){
- window.clearTimeout(_this._timeoutID);
- }
- if(_this._request.status == 200){
- try {
- LOG.debug("Response with content-type: "+
_this.getResponseHeader('Content-Type'));
- LOG.debug("Full response content: ", _this.getResponseText());
- } catch(e) {
- // IE Can throw exception for any responses
- }
- // Prepare XML, if exist.
- if(_this._request.responseXML ){
- _this._parsingStatus =
Sarissa.getParseErrorText(_this._request.responseXML);
- if(_this._parsingStatus == Sarissa.PARSED_OK &&
Sarissa.setXpathNamespaces ){
-
Sarissa.setXpathNamespaces(_this._request.responseXML,"xmlns='ht...;
- }
- }
- if(_this.onready){
- _this.onready(_this);
- }
- } else {
- _this._errorMessage = "Reqest error, status :
"+_this._request.status +" " + _this._request.statusText + "\n
Message: " + _this.getResponseHeader("Ajax-Error-Message");
- LOG.error(_this._errorMessage);
- if(typeof(_this._onerror) == "function"){
- _this._onerror(_this,_this._request.status,_this._errorMessage);
- }
- }
- if(_this.onfinish){
- _this.onfinish(_this);
- }
- _this = undefined;
- }
- }; //this._onReady;
- try{
- LOG.debug("Start XmlHttpRequest");
- this._request.open('POST', this._query.getActionUrl("") , true);
- // Query use utf-8 encoding for prepare urlencode data, force request content-type
and charset.
- var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
- this._request.setRequestHeader( "Content-Type", contentType);
- } catch(e){
- // Opera 7-8 - force get
- LOG.debug("XmlHttpRequest not support setRequestHeader - use GET instead of
POST");
- this._request.open('GET',
this._query.getActionUrl("")+"?"+this._query.getQueryString() ,
true);
- }
- // send data.
- this._request.send(this._query.getQueryString());
- if(this._timeout > 0){
- this._timeoutID = window.setTimeout(function(){
- LOG.warn("request stopped due to timeout");
- if(!_this._aborted){
- A4J.AJAX.status(_this.containerId,_this.options.status,false);
- if(typeof(A4J.AJAX.onAbort) == "function"){
- A4J.AJAX.onAbort(_this);
- }
- }
- _this._aborted=true;
- _this._request.abort();
- if(_this._onerror){
- _this._errorMessage = "Request timeout";
- _this._onerror(_this,500,_this._errorMessage);
- }
- if(_this.onfinish){
- _this.onfinish(_this);
- }
- _this._request=undefined;
- _this = undefined;
- },this._timeout);
- }
- },
-
- abort: function(){
- if(!this._aborted){
- A4J.AJAX.status(this.containerId,this.options.status,false);
- if(typeof(A4J.AJAX.onAbort) == "function"){
- A4J.AJAX.onAbort(this);
- }
- }
- this._aborted=true;
- if(this._request){
- try{
- this._request.abort();
- if(this._timeoutID){
- window.clearTimeout(this._timeoutID);
- }
- } catch (e){
- LOG.warn("Exception for abort current request "+e.Message);
- }
- }
- },
- getResponseText : function(){
- return this._request.responseText;
- },
- getError : function(){
- return this._errorMessage;
- },
- getParserStatus : function(){
- return this._parsingStatus;
- },
- getContentType : function(){
- if(!this._contentType){
- var contentType = this.getResponseHeader('Content-Type');
- if(contentType){
- var i = contentType.indexOf(';');
- if( i >= 0 ){
- this._contentType = contentType.substring(0,i);
- } else {
- this._contentType = contentType;
- }
- } else {
- this._contentType="text/html";
- }
- }
- return this._contentType;
- },
- getResponseHeader : function(name){
- var result;
- // Different behavior - for non-existing headers, Firefox throws exception,
- // IE return "" ,
- try{
- result = this._request.getResponseHeader(name);
- if(result === ""){
- result = undefined;
- }
- } catch(e) {
- }
- if(!result){
- // Header not exist or Opera <=8.0 error. Try to find <meta > tag with same
name.
- LOG.debug("Header "+name+" not found, search in <meta>");
- if(this._parsingStatus == Sarissa.PARSED_OK){
- var metas = this.getElementsByTagName("meta");
- for(var i = 0; i < metas.length;i++){
- var meta = metas[i];
- LOG.debug("Find <meta
name='"+meta.getAttribute('name')+"'
content='"+meta.getAttribute('content')+"'>");
- if(meta.getAttribute("name") == name){
- result = meta.getAttribute("content");
- break;
- }
- }
- }
-
- }
- return result;
- },
- /**
- * get elements with elementname in responseXML or, if present - in element.
- */
- getElementsByTagName : function(elementname,element){
- if(!element){
- element = this._request.responseXML;
- }
- LOG.debug("search for elements by name '"+elementname+"'
"+" in element "+element.nodeName);
- var elements;
- try
- {
- elements = element.selectNodes(".//*[local-name()=\""+
- elementname +"\"]");
- LOG.debug("selectNodes found "+elements.length);
- }
- catch (ex) {
- elements = element.getElementsByTagName(elementname);
- LOG.debug("getElementsByTagName found "+elements.length);
- }
-// return document.getElementsByTagName(tagName);
-// elements =
element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml",e...;
-// LOG.debug("getElementsByTagNameNS found "+elements.length);
- return elements;
- },
- /**
- * Find element in response by ID. Since in IE response not validated, use
selectSingleNode instead.
- */
- getElementById : function(id){
- // first attempt - .getElementById.
- var oDoc = this._request.responseXML;
- if(typeof(oDoc.getElementById) != 'undefined') {
- LOG.debug("call getElementById for id= "+id);
- return oDoc.getElementById(id);
- }
- else if(typeof(oDoc.selectSingleNode) != "undefined") {
- LOG.debug("call selectSingleNode for id= "+id);
- return oDoc.selectSingleNode("//*[@id='"+id+"']"); /*
XPATH istead of ID */
- }
- // nodeFromID not worked since XML validation disabled by
- // default for MS
- else if(typeof(oDoc.nodeFromID) != "undefined") {
- LOG.debug("call nodeFromID for id= "+id);
- return oDoc.nodeFromID(id);
- }
- LOG.error("No functions for getElementById found ");
- return null;
-
- },
-
- getJSON : function(id){
- var data;
- var dataElement = this.getElementById(id);
- if(dataElement){
- try {
- data = Sarissa.getText(dataElement,true);
- data = window.eval('('+data+')');
- } catch(e){
- LOG.error("Error on parsing JSON data "+e.message,data);
- }
- }
- return data;
- },
-
- evalScripts : function(node){
- var newscripts = this.getElementsByTagName("script",node);
- LOG.debug("Scripts in updated part count : " + newscripts.length);
- if( newscripts.length > 0 ){
- window.setTimeout(function() {
- for (var i = 0; i < newscripts.length; i++){
- var newscript = Sarissa.getText( newscripts[i],true ) ; // TODO - Mozilla
disable innerHTML in XML page ..."";
- try {
- LOG.debug("Evaluate script replaced area in document: ",
newscript);
- if (window.execScript) {
- window.execScript( newscript );
- } else {
- window.eval(newscript);
- }
- } catch(e){
- LOG.error("ERROR Evaluate script: Error name: " + e.name +
e.message?". Error message: "+e.message:"");
- }
- }
- newscripts = null;
- },50);
- }
-
- },
- /**
- * Update DOM element with given ID by element with same ID in parsed responseXML
- */
- updatePagePart : function(id){
- var newnode = this.getElementById(id);
- if( ! newnode ) { LOG.error("New node for ID "+id+" is not present in
response");return;}
- var oldnode = window.document.getElementById(id);
- if ( oldnode ) {
- var anchor = oldnode.parentNode ;
- // need to check for firstChild due to opera 8 bug with hasChildNodes
- Sarissa.clearChildNodes(oldnode);
- if(oldnode.outerHTML){
- LOG.debug("Replace content of node by outerHTML()");
- oldnode.outerHTML = new XMLSerializer().serializeToString(newnode);
- } else {
- var importednode ;
- importednode = window.document.importNode(newnode, true);
- LOG.debug("Replace content of node by replaceChild()");
- anchor.replaceChild(importednode,oldnode);
- }
- // re-execute all script fragments in imported subtree...
- // TODO - opera 8 run scripts at replace content stage.
- if(!A4J.AJAX._scriptEvaluated){
- this.evalScripts(newnode);
- }
- LOG.debug("Update part of page for Id: "+id + "
successful");
- } else {
- LOG.warn("Node for replace by response with id "+id+" not found in
document");
- }
-
- },
-
- appendNewHeadElements : function(){
- // Append scripts and styles to head, if not presented in page before.
-
this._appendNewElements("script","src",["type","language","charset"]);
-
this._appendNewElements("link","href",["type","rel","rev","media"]);
- },
-
- _appendNewElements : function(tag,href,attributes){
- var newscripts = this.getElementsByTagName(tag);
- var oldscripts = document.getElementsByTagName(tag);
- var head =
document.getElementsByTagName("head")[0]||document.documentElement;
- for(var i=0 ; i<newscripts.length;i++){
- var element = newscripts[i];
- var src = element.getAttribute(href);
- if(src){
- var exist = false;
- LOG.debug("<"+tag+"> in response with
src="+src);
- for(var j = 0 ; j < oldscripts.length; j++){
- if(src == oldscripts[j].getAttribute(href)){
- LOG.debug("Such element exist in document");
- exist = true;
- break;
- }
- }
- if(!exist){
- // var script = window.document.importNode(element,true); //
- var script = document.createElement(tag);
- script.setAttribute(href,src);
- for(var j = 0 ; j < attributes.length; j++){
- this._copyAttribute(element,script,attributes[j]);
- }
- LOG.debug("append element to document");
- head.appendChild(script);
- }
- }
- }
-
- },
-
- _copyAttribute : function(src,dst,attr){
- var value = src.getAttribute(attr);
- if(value){
- dst.setAttribute(attr,value);
- }
- }
-
-};
-// eventsQueues for ajax submit events.
-A4J.AJAX._eventsQueues={};
-
-//Listeners should be notified
-A4J.AJAX.Listener = function(onafterajax){
- this.onafterajax = onafterajax;
-};
-
-A4J.AJAX._listeners= [];
-A4J.AJAX.AddListener = function(listener){
- A4J.AJAX._listeners.push(listener);
-};
-A4J.AJAX.removeListeners = function(listener){
- A4J.AJAX._listeners = [];
-};
-// pollers timerId's
-A4J.AJAX._pollers = {};
-/*
- *
- *
- */
-A4J.AJAX.Poll = function( containerId, form, options ) {
- A4J.AJAX.StopPoll(options.pollId);
- options.onerror = function(){
- // For error, re-submit request.
- A4J.AJAX.Poll(containerId,form,options);
- };
- A4J.AJAX._pollers[options.pollId] = window.setTimeout(function(){
- A4J.AJAX._pollers[options.pollId]=undefined;
- A4J.AJAX.SubmitRequest(containerId,form,null,options);
- },options.pollinterval);
-};
-
-A4J.AJAX.StopPoll = function( Id ) {
- if(A4J.AJAX._pollers[Id]){
- window.clearTimeout(A4J.AJAX._pollers[Id]);
- A4J.AJAX._pollers[Id] = undefined;
- }
-};
-
-
-A4J.AJAX.CloneObject = function( obj, noFunctions ) {
- var cloned = {};
- for( var n in obj ){
- if(noFunctions && typeof(evt[prop]) == 'function'){
- continue;
- }
- cloned[n]=obj[n];
- }
- return cloned;
-}
-
-
-A4J.AJAX.SubmitForm = function( containerId, form, options ) {
- var opt = A4J.AJAX.CloneObject(options);
- // Setup active control if form submitted by button.
- if(A4J._formInput){
- LOG.debug("Form submitted by button "+A4J._formInput.id);
- opt.control = A4J._formInput;
- A4J._formInput = null;
- }
- A4J.AJAX.Submit(containerId,form,null,opt);
-}
-
-// Submit or put in queue request. It not full queues - framework perform waiting only
one request to same queue, new events simple replace last.
-// If request for same queue already performed, replace with current parameters.
-A4J.AJAX.Submit = function( containerId, form, evt , options ) {
- var domEvt;
- evt = evt || window.event || null;
- if(evt){
- // Create copy of event object, since most of properties undefined outside of event
capture.
- try {
- domEvt = A4J.AJAX.CloneObject(evt,false);
- } catch(e){
- LOG.warn("Exception on clone event");
- }
- LOG.debug("Have Event "+domEvt+" with properties: target:
"+domEvt.target+", srcElement: "+domEvt.srcElement+", type:
"+domEvt.type);
- }
- if(options.eventsQueue){
- var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
- if( eventsQueue ) {
- var eventsCount = eventsQueue.options.eventsCount||1;
- eventsQueue.wait=true;
- eventsQueue.containerId=containerId;
- eventsQueue.form=form;
- eventsQueue.domEvt=domEvt;
- eventsQueue.options=options;
- eventsQueue.options.eventsCount = eventsCount+1;
- if(options.ignoreDupResponses && eventsQueue.request){
- LOG.debug("Abort uncompleted request in queue
"+options.eventsQueue);
- eventsQueue.request.abort();
- eventsQueue.request=false;
- eventsQueue.wait=false;
- if( options.requestDelay ){
- window.setTimeout(function() {
- LOG.debug("End delay waiting, make request in queue
"+options.eventsQueue);
- A4J.AJAX.SubmiteventsQueue(A4J.AJAX._eventsQueues[options.eventsQueue]);
- },options.requestDelay);
- LOG.debug("Create new waiting for request in queue
"+options.eventsQueue);
- return;
- }
- } else {
- LOG.debug("Put new event to queue "+options.eventsQueue);
- return;
- }
- } else {
- var queue = { wait : false, containerId : containerId , form : form, domEvt :
domEvt, options : options};
- A4J.AJAX._eventsQueues[options.eventsQueue] = queue;
- if( options.requestDelay ){
- window.setTimeout(function() {
- LOG.debug("End delay waiting, make request in queue
"+options.eventsQueue);
- A4J.AJAX.SubmiteventsQueue(A4J.AJAX._eventsQueues[options.eventsQueue]);
- },options.requestDelay);
- LOG.debug("Event occurs, create waiting for request in queue
"+options.eventsQueue);
- return;
- }
- }
- }
- A4J.AJAX.SubmitRequest( containerId, form, domEvt , options );
-};
-
-A4J.AJAX.SubmiteventsQueue = function( eventsQueue ) {
- // Clear wait flag to avoid resend same request.
- eventsQueue.wait=false;
- A4J.AJAX.SubmitRequest( eventsQueue.containerId, eventsQueue.form ,eventsQueue.domEvt ,
eventsQueue.options );
-};
- // Main request submitting functions.
- // parameters :
- // form - HtmlForm object for submit.
- // control - form element, called request, or, clientID for JSF view.
- // affected - Array of ID's for DOM Objects, updated after request. Override
- // list of updated areas in response.
- // statusID - DOM id request status tags.
- // oncomplete - function for call after complete request.
-A4J.AJAX.SubmitRequest = function( containerId, formId ,domEvt , options ) {
- // First - run onsubmit event for client-side validation.
- LOG.debug("NEW AJAX REQUEST !!! with form :"+formId );
-// var form = A4J.AJAX.locateForm(event);
- var form = window.document.getElementById(formId);
- if( (!form || form.nodeName.toUpperCase() != "FORM") && domEvt ) {
- var srcElement = domEvt.target||domEvt.srcElement||null;
- if(srcElement){
- form = A4J.AJAX.locateForm(srcElement);
- };
- };
- // TODO - test for null of form object
- if(form && form.onsubmit) {
- LOG.debug("Form have onsubmit function, call it" );
- if( form.onsubmit() == false ){
- return false;
- };
- };
- var tosend = new A4J.Query(containerId, form);
- tosend.appendFormControls(options.single);
- if(options.control){
- tosend.appendControl(options.control,true);
- };
- if(options.parameters){
- tosend.appendParameters(options.parameters);
- };
- if(options.eventsCount){
- tosend.appendParameter("AJAX:EVENTS_COUNT",options.eventsCount);
- };
- if(options.actionUrl){
- tosend.setActionUrl(options.actionUrl);
- };
- // build xxxHttpRequest. by Sarissa / JSHttpRequest class always defined.
- var req = new A4J.AJAX.XMLHttpRequest(tosend);
-
- req.options = options;
- req.containerId = containerId;
- req.domEvt = domEvt;
- req.form = form;
- if(options.timeout){
- req.setRequestTimeout(options.timeout);
- };
-
- // Event handler for process response result.
- req.onready = A4J.AJAX.processResponse;
-
- if(options.onerror){
- req._onerror = options.onerror;
- } else if(typeof(A4J.AJAX.onError)== "function"){
- req._onerror = A4J.AJAX.onError;
- }
- req.onfinish = A4J.AJAX.finishRequest;
-
- A4J.AJAX.status(containerId,options.status,true);
- req.send();
- if(options.eventsQueue){
- var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
- if( eventsQueue ) {
- eventsQueue.request=req;
- }
- }
-
- return false;
- };
-
-
-
-A4J.AJAX.processResponse = function(req) {
- var options = req.options;
- var ajaxResponse = req.getResponseHeader('Ajax-Response');
- if( ajaxResponse != "true"){
- // NO Ajax header - new page.
- LOG.warn("No ajax response header ");
- var loc = req.getResponseHeader("Location");
- try{
- if(ajaxResponse == 'redirect' && loc){
- var expiredMsg = req.getResponseHeader('Ajax-Expired');
- if(expiredMsg){
- loc = A4J.AJAX.onExpired(loc,expiredMsg);
- if(!loc){
- return;
- }
- }
- window.location = loc;
- } else if(ajaxResponse == "reload"){
- window.location.reload(true);
- } else {
- var isIE = _SARISSA_IS_IE;
- // maksimkaszynski
- //Prevent "Permission denied in IE7"
- //Reset calling principal
- if (isIE) {
- var oldDocOpen = window.document.open;
- window.document.open = function() {
- oldDocOpen.apply(this, arguments);
- }
- }
- // /maksimkaszynski
- window.setTimeout(function() {
- var isDocOpen=false;
- try {
- window.document.open(req.getContentType(),true);
- isDocOpen=true;
- window.document.write(req.getResponseText());
- window.document.close();
- if(isIE){
- // For Ie , scripts on page not activated.
- window.location.reload(false);
- }
- } catch(e) {
- if(isDocOpen){
- window.document.close();
- }
- // Firefox/Mozilla in XHTML case don't support document.write()
-// window.location =
"data:"+req.getContentType()+";charset=utf-8," +
encodeURIComponent(req.getResponseText())
- // Use dom manipulation instead.
- var oDomDoc = (new DOMParser()).parseFromString(req.getResponseText(),
"application/xhtml+xml");
- var node = window.document.importNode(oDomDoc.documentElement, true);
- window.document.replaceChild(node,window.document.documentElement);
- // TODO - scripts reloading ?
- }
- },30);
- }
- } catch(e){
- LOG.error("Error redirect to new location ");
- }
- } else {
- if(req.getParserStatus() == Sarissa.PARSED_OK){
- var idsFromResponse = req.getResponseHeader("Ajax-Update-Ids");
- // 3 strategy for replace :
- // if setted affected parameters - replace its
- if( options.affected ) {
- req.appendNewHeadElements();
- for ( var k =0; k < options.affected.length ; k++ ) {
- LOG.debug("Update page part from call parameter for ID " +
options.affected[k]);
- req.updatePagePart(options.affected[k]);
- };
- // if resopnce contains element with ID "ajax:update" get id's from
- // child text element . like :
- // <div id="ajax:update" style="display none" >
- // <span>_id1:1234</span>
- // .........
- // </div>
- //
- } else if( idsFromResponse != "" ) {
- LOG.debug("Update page by list of rendered areas from response " +
idsFromResponse );
- // Append scripts and styles to head, if not presented in page before.
- req.appendNewHeadElements();
- var childs = idsFromResponse.split(",");
- for ( var k=0 ; k < childs.length ; k++ ) {
- var id = childs[k];
- LOG.debug("Attempt to update part of page for Id: "+id);
- if ( id ) {req.updatePagePart(id);};
- };
- } else {
- // if none of above - error ?
- // A4J.AJAX.replace(form.id,A4J.AJAX.findElement(form.id,xmlDoc));
- LOG.warn("No information in response about elements to replace");
- }
- // Replace client-side hidden inputs for JSF View state.
- var idsSpan = req.getElementById("ajax-update-ids");
- LOG.debug("Hidden JSF state fields: "+idsSpan);
- if(idsSpan != null){
- // For a portal case, replace content in the current window only.
- var namespace = options.parameters['org.ajax4jsf.portlet.NAMESPACE'];
- LOG.debug("Namespace for hidden view-state input fields is
"+namespace);
- var anchor =
namespace?window.document.getElementById(namespace):window.document;
- var inputs = anchor.getElementsByTagName("input");
- var newinputs = req.getElementsByTagName("input",idsSpan);
- A4J.AJAX.replaceViewState(inputs,newinputs);
- // For any cases, new state can be in uppercase element
- newinputs = req.getElementsByTagName("INPUT",idsSpan);
- A4J.AJAX.replaceViewState(inputs,newinputs);
- }
- // Process listeners.
- for(var li = 0; li < A4J.AJAX._listeners.length; li++){
- var listener = A4J.AJAX._listeners[li];
- if(listener.onafterajax){
- // Evaluate data as JSON String.
- var data = req.getJSON('_ajax:data');
- listener.onafterajax(req,req.domEvt,data);
- }
- }
- // Set focus, if nessesary.
- var responseFocus = req.getElementById("_A4J.AJAX.focus");
- if(responseFocus){
- var focusId = Sarissa.getText(responseFocus,true);
- var focusElement=false;
- if(req.form){
- // Attempt to get form control for name. By Richfaces naming convensions,
- // complex component must set clientId as DOM id for a root element ,
- // and as input element name.
- focusElement = req.form.elements[focusId];
- }
- if(!focusElement){
- // If not found as control element, search in DOM.
- focusElement = document.getElementById(focusId);
- }
- if(focusElement){
- focusElement.focus();
- }
- }
- } else {
- // No response XML
- LOG.error( "Error parsing XML" );
- LOG.error("Parse Error: " + req.getParserStatus());
- }
- }
- };
-
-A4J.AJAX.onExpired = function(loc,expiredMsg){
- if(window.confirm(expiredMsg)){
- return loc;
- } else {
- return undefined;
- }
-};
-
-
-A4J.AJAX.replaceViewState = function(inputs,newinputs){
- LOG.debug("Replace value for inputs: "+inputs.length + " by
new values: "+ newinputs.length);
- if( (newinputs.length > 0) && (inputs.length > 0) ){
- for(var i = 0 ; i < newinputs.length; i++){
- var newinput = newinputs[i];
- LOG.debug("Input in response:
"+newinput.getAttribute("name"));
- for(var j = 0 ; j < inputs.length; j++){
- var input = inputs[j];
- if(input.name == newinput.getAttribute("name")){
- LOG.debug("Found same input on page with type: "+input.type);
- input.value = newinput.getAttribute("value");
- }
- }
- }
- }
-
-};
-/**
- *
- */
-A4J.AJAX.finishRequest = function(req){
- var options = req.options;
- // mark status object ( if any ) for complete request ;
- A4J.AJAX.status(req.containerId,options.status,false);
- // we can set listener for complete request - for example,
- // it can shedule next request for update page.
- if(options.oncomplete){
- LOG.debug( "Call request oncomplete function after processing updates"
);
- window.setTimeout(function(){
- options.oncomplete(req,req.domEvt,req.getJSON('_ajax:data'));},
- 50);
-
- }
- // If we have events in queue - send next request.
- if(options.eventsQueue){
- var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
- if( eventsQueue ) {
- A4J.AJAX._eventsQueues[options.eventsQueue]=false;
- if(eventsQueue.wait){
- LOG.debug("Queue not empty, execute next request in queue
"+options.eventsQueue);
- A4J.AJAX.SubmiteventsQueue(eventsQueue);
- }
- }
- }
- };
-
- // Locate enclosing form for object.
-A4J.AJAX.locateForm = function(obj){
-
- var parent = obj;
- while(parent && parent.nodeName.toLowerCase() != 'form'){
- parent = parent.parentNode;
- };
- return parent;
-
- };
-
-A4J.AJAX.getElementById = function(id,options){
- var namespace = options['org.ajax4jsf.portlet.NAMESPACE'];
- var anchor = namespace?window.document.getElementById(namespace):window.document;
- var element;
- if(anchor){
- element = anchor.getElementById(id);
- } else {
- LOG.error("No root element for portlet namespace "+namespace+" on
page");
- }
- return element;
-}
-
- // hash for requests count for all ID's
-A4J.AJAX._requestsCounts = {};
- // Change status object on start/stop request.
- // on start, document object with targetID+".start" make visible,
- // document object with targetID+".stop" make invisible.
- // on stop - inverse.
-A4J.AJAX.status = function(regionID,targetID,start){
- try {
- var elem;
- targetID = targetID || regionID +":status";
-
A4J.AJAX._requestsCounts[targetID]=(A4J.AJAX._requestsCounts[targetID]||0)+(start?1:-1);
- if(A4J.AJAX._requestsCounts[targetID]>0){
- elem = document.getElementById(targetID+".stop");
- if(elem){elem.style.display="none";}
- elem = document.getElementById(targetID+".start");
- if(elem){
- elem.style.display="";
- if(typeof(elem.onstart) == 'function'){
- elem.onstart();
- }
- }
- }else{
- elem = document.getElementById(targetID+".start");
- if(elem){elem.style.display="none";}
- elem = document.getElementById(targetID+".stop");
- if(elem){
- elem.style.display="";
- if(typeof(elem.onstop) == 'function'){
- elem.onstop();
- }
- }
- }
- } catch(e){
- LOG.error("Exception on status change: ");
- }
-};
-
-
-
-
-// Class for build query string.
-A4J.Query = function(containerId,form){
- // For detect AJAX Request.
- this._query = {AJAXREQUEST : containerId};
- this._oldSubmit = null ;
- this._form = form ;
- this._actionUrl = ( this._form.action)?this._form.action:this._form;
- };
-
-A4J.Query.prototype = {
- _form : null,
- _actionUrl : null,
- _ext : "",
- _query : {},
- _oldSubmit : null,
- // init at loading time - script can change location at run time ? ...
- _pageBase : window.location.protocol+"//"+window.location.host,
- // hash for control elements query string functions
-
- hidden : function(control){
- this._value_query(control);
- // TODO - configurable mask for hidden command scripts.
- if( (control.name.length > 4) &&
(control.name.lastIndexOf("_idcl") == (control.name.length-5)) ){
- control.value="";
- // MYfaces version ...
- } else if( (control.name.length > 12) &&
(control.name.lastIndexOf("_link_hidden_") == (control.name.length-13)) ){
- control.value="";
- }
- },
-
- text : function(control){
- this._value_query(control);
- },
-
- textarea : function(control){
- this._value_query(control);
- },
-
- 'select-one' : function(control){
- // If none options selected, don't include parameter.
- if (control.selectedIndex != -1) {
- this._value_query(control);
- }
-// for( var i =0; i< control.childNodes.length; i++ ){
-// var child=control.childNodes[i];
-// if( child.selected ){
-// this._value_query(control);
-// break;
-// }
-// }
- },
-
- password : function(control){
- this._value_query(control);
- },
-
- file : function(control){
- this._value_query(control);
- },
-
- radio : function(control){
- this._check_query(control);
- },
-
- checkbox : function(control){
- this._check_query(control);
- },
-
-
- 'select-multiple' : function(control){
- var cname = control.name;
- var childs = control.childNodes;
- for( var i=0 ;i< childs.length;i++ ){
- var child=childs[i];
- if( child.tagName == 'OPTGROUP' ){
- var options = child.childNodes;
- for(var j=0; j < options.length; j++){
- this._addOption(cname, options[j]);
- }
- } else {
- this._addOption(cname, child);
- }
- }
- },
-
- _addOption : function(cname,option){
- if ( option.selected ){
- if( ! this._query[cname] ){
- this._query[cname]=[];
- }
- this._query[cname][this._query[cname].length]=option.value;
- }
-
- },
-// command inputs
-
- image : function( control, action ){
- if(action) this._value_query(control);
- },
- button : function( control, action ){
- if(action) this._value_query(control);
- },
-
- submit : function( control, action ){
- if(action) {
- this._value_query(control);
- }
- },
-
- // Anchor link pseudo-control.
- link : function(control, action ){
- if(action) {
- this._value_query(control);
- if(control.parameters){
- this.appendParameters(control.parameters);
- }
- }
- },
-
- // same as link, but have additional field - control, for input submit.
- input : function(control, action ){
- if(action) {
- this.link(control, action );
- // append original control.
- if( control.control ) {
- this.appendControl(control.control,action);
- }
- }
- },
-
- // Append one control to query.
- appendControl : function(control,action){
- if( this[control.type] ) {
- this[control.type](control,action);
- } else {
- this._appendById(control.id||control);
- }
-
- },
-
- // Append all non-hidden controls from form to query.
- appendFormControls : function(hiddenOnly){
- try {
- var elems = this._form.elements;
- if(elems){
- var k = 0;
- for ( k=0;k<elems.length;k++ ) {
- var element=elems[k];
- try {
- if( !hiddenOnly || element.type == "hidden") {
- this.appendControl(element,false) ;
- }
- } catch( ee ) {
- LOG.error("exception in building query ( append form control ) " +
ee );
- }
- }
- }
- } catch(e) {
- LOG.warn("Error with append form controls to query "+e)
- }
- },
-
- // append map of parameters to query.
- appendParameters : function(parameters){
- for( k in parameters ){
- if(typeof Object.prototype[k] == 'undefined'){
- LOG.debug( "parameter " + k + " with value
"+parameters[k]);
- this.appendParameter(k,parameters[k]);
- }
- }
- },
-
- setActionUrl : function(actionUrl){
- this._actionUrl = actionUrl;
- },
-// Return action URL ( append extention, if present )
- getActionUrl : function( ext ) {
- var actionUrl = this._actionUrl ;
- var ask = actionUrl.indexOf('?');
- // create absolute reference - for Firefox XMLHttpRequest base url can vary
- if( actionUrl.substring(0,1) == '/' ) {
- actionUrl = this._pageBase+actionUrl;
- }
- if ( ! ext ) ext = this._ext ;
- if( ask >=0 )
- {
- return actionUrl.substring(0,ask) + ext + actionUrl.substring(ask);
- }
- else return actionUrl + ext;
- },
-
-
-// Build query string for send to server.
- getQueryString : function() {
- var qs = "";
- var iname ;
- for ( var k in this._query ){
- if(typeof Object.prototype[k] == 'undefined'){
- iname = this._query[k];
- if( iname instanceof Object ){
- for ( var l=0; l< iname.length; l++ ) {
- qs += this._encode(k) + "=" + this._encode(iname[l]) +
"&";
- }
- } else {
- qs += this._encode(k) + "=" + this._encode(iname) + "&";
- }
- }
- }
- LOG.debug("QueryString: "+qs);
- return qs;
- },
- // private methods
-
- _appendById : function( id ) {
- this.appendParameter(this._form.id + "_link_hidden_", id);
- // JSF-ri version ...
- // this._query[this._form.id + "_idcl"]=id;
- },
-
-
- _value_query : function(control){
- LOG.debug("Append "+control.type+" control "+control.name+"
with value ["+control.value+"] and value attribute
["+control.getAttribute('value')+"]");
- if(null != control.value){
- this.appendParameter(control.name, control.value);
- }
- },
-
- _check_query : function(control){
- if( control.checked ) {
- this.appendParameter(control.name, control.value?control.value:"on");
- }
- },
-
- // Append parameter to query. if name exist, append to array of parameters
- appendParameter: function(cname,value){
- if( ! this._query[cname] ){
- this._query[cname]=value;
- return;
- } else if( !(this._query[cname] instanceof Object) ){
- this._query[cname] = [this._query[cname]];
- }
- this._query[cname][this._query[cname].length]=value;
- },
-
- // Encode data string for request string
- _encode : function(string) {
- try {
- return encodeURIComponent(string);
- } catch(e) {
- var str = escape(string);
- // escape don't encode +. but form replace ' ' in fields by
'+'
- return str.split('+').join('%2B');
- }
- }
-
-
- }
-
-// Test for re-evaluate Scripts in updated part. Opera & Safari do it.
-A4J.AJAX._scriptEvaluated=false;
-if (!document.all || window.opera){
- setTimeout(function(){
- try{
- // Simulate same calls as on XmlHttp
- var oDomDoc = Sarissa.getDomDocument();
- var _span = document.createElement("span");
- document.documentElement.appendChild(_span);
- // If script evaluated with used replace method, variable will be set to true
- var xmlString = "<html
xmlns='http://www.w3.org/1999/xhtml'><sc"+"ript&g...;
- oDomDoc = (new DOMParser()).parseFromString(xmlString, "text/xml");
- var _script=oDomDoc.getElementsByTagName("script")[0];
- if(_span.outerHTML){
- _span.outerHTML = new XMLSerializer().serializeToString(_script);
- } else {
- var importednode ;
- importednode = window.document.importNode(_script, true);
- document.documentElement.replaceChild(importednode,_span);
- }
-
- } catch(e){ /* Mozilla in XHTML mode not have innerHTML */ };
- },50);
-}
Copied: tags/1_1_1_rc1/framework/src/main/javascript/ajaxjsf/JSFAJAX.js (from rev 166,
trunk/framework/src/main/javascript/ajaxjsf/JSFAJAX.js)
===================================================================
--- tags/1_1_1_rc1/framework/src/main/javascript/ajaxjsf/JSFAJAX.js
(rev 0)
+++ tags/1_1_1_rc1/framework/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-05-04 01:10:03
UTC (rev 168)
@@ -0,0 +1,1174 @@
+// Global Variables
+// var timeout = null;
+
+// TODO - use sarissa for standard XMLHttpRequest Support.
+
+
+// AJAX-JSF AJAX-like library, for communicate with view Tree on server side.
+
+// Modified by Alexander J. Smirnov to use as JSF AJAX-like components.
+
+A4J.AJAX = {};
+
+/**
+ * XMLHttp transport class - incapsulate most of client-specifiv functions for call
server requests.
+ */
+A4J.AJAX.XMLHttpRequest = function(query){
+ this._query = query;
+ };
+
+A4J.AJAX.XMLHttpRequest.prototype = {
+ _query : null,
+ _timeout : 0,
+ _timeoutID : null,
+ onready : null,
+ _parsingStatus : Sarissa.PARSED_EMPTY,
+ _errorMessage : "XML Response object not set",
+ _contentType : null,
+ _onerror : function(req,status,message) {
+ // Status not 200 - error !!!! TODO - I18N ???
+ window.alert(message);
+ },
+ onfinish : null,
+ options : {},
+ domEvt : null,
+ form : null,
+ _request : null,
+ _aborted : false,
+
+ setRequestTimeout : function(timeout){
+ this._timeout = timeout;
+ },
+ /**
+ * Send request to server with parameters from query ( POST or GET depend on client type
)
+ */
+ send : function(){
+ this._request = new XMLHttpRequest();
+ var _this = this;
+ this._request.onreadystatechange = function(){
+ if(_this._aborted){return;};
+ LOG.debug("Reqest state : "+_this._request.readyState );
+ if (_this._request.readyState == 4 ) {
+ LOG.debug("Reqest end with state 4");
+ if(_this._timeoutID){
+ window.clearTimeout(_this._timeoutID);
+ }
+ if(_this._request.status == 200){
+ try {
+ LOG.debug("Response with content-type: "+
_this.getResponseHeader('Content-Type'));
+ LOG.debug("Full response content: ", _this.getResponseText());
+ } catch(e) {
+ // IE Can throw exception for any responses
+ }
+ // Prepare XML, if exist.
+ if(_this._request.responseXML ){
+ _this._parsingStatus =
Sarissa.getParseErrorText(_this._request.responseXML);
+ if(_this._parsingStatus == Sarissa.PARSED_OK &&
Sarissa.setXpathNamespaces ){
+
Sarissa.setXpathNamespaces(_this._request.responseXML,"xmlns='ht...;
+ }
+ }
+ if(_this.onready){
+ _this.onready(_this);
+ }
+ } else {
+ _this._errorMessage = "Reqest error, status :
"+_this._request.status +" " + _this._request.statusText + "\n
Message: " + _this.getResponseHeader("Ajax-Error-Message");
+ LOG.error(_this._errorMessage);
+ if(typeof(_this._onerror) == "function"){
+ _this._onerror(_this,_this._request.status,_this._errorMessage);
+ }
+ }
+ if(_this.onfinish){
+ _this.onfinish(_this);
+ }
+ _this = undefined;
+ }
+ }; //this._onReady;
+ try{
+ LOG.debug("Start XmlHttpRequest");
+ this._request.open('POST', this._query.getActionUrl("") , true);
+ // Query use utf-8 encoding for prepare urlencode data, force request content-type
and charset.
+ var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
+ this._request.setRequestHeader( "Content-Type", contentType);
+ } catch(e){
+ // Opera 7-8 - force get
+ LOG.debug("XmlHttpRequest not support setRequestHeader - use GET instead of
POST");
+ this._request.open('GET',
this._query.getActionUrl("")+"?"+this._query.getQueryString() ,
true);
+ }
+ // send data.
+ this._request.send(this._query.getQueryString());
+ if(this._timeout > 0){
+ this._timeoutID = window.setTimeout(function(){
+ LOG.warn("request stopped due to timeout");
+ if(!_this._aborted){
+ A4J.AJAX.status(_this.containerId,_this.options.status,false);
+ if(typeof(A4J.AJAX.onAbort) == "function"){
+ A4J.AJAX.onAbort(_this);
+ }
+ }
+ _this._aborted=true;
+ _this._request.abort();
+ if(_this._onerror){
+ _this._errorMessage = "Request timeout";
+ _this._onerror(_this,500,_this._errorMessage);
+ }
+ if(_this.onfinish){
+ _this.onfinish(_this);
+ }
+ _this._request=undefined;
+ _this = undefined;
+ },this._timeout);
+ }
+ },
+
+ abort: function(){
+ if(!this._aborted){
+ A4J.AJAX.status(this.containerId,this.options.status,false);
+ if(typeof(A4J.AJAX.onAbort) == "function"){
+ A4J.AJAX.onAbort(this);
+ }
+ }
+ this._aborted=true;
+ if(this._request){
+ try{
+ this._request.abort();
+ if(this._timeoutID){
+ window.clearTimeout(this._timeoutID);
+ }
+ } catch (e){
+ LOG.warn("Exception for abort current request "+e.Message);
+ }
+ }
+ },
+ getResponseText : function(){
+ return this._request.responseText;
+ },
+ getError : function(){
+ return this._errorMessage;
+ },
+ getParserStatus : function(){
+ return this._parsingStatus;
+ },
+ getContentType : function(){
+ if(!this._contentType){
+ var contentType = this.getResponseHeader('Content-Type');
+ if(contentType){
+ var i = contentType.indexOf(';');
+ if( i >= 0 ){
+ this._contentType = contentType.substring(0,i);
+ } else {
+ this._contentType = contentType;
+ }
+ } else {
+ this._contentType="text/html";
+ }
+ }
+ return this._contentType;
+ },
+ getResponseHeader : function(name){
+ var result;
+ // Different behavior - for non-existing headers, Firefox throws exception,
+ // IE return "" ,
+ try{
+ result = this._request.getResponseHeader(name);
+ if(result === ""){
+ result = undefined;
+ }
+ } catch(e) {
+ }
+ if(!result){
+ // Header not exist or Opera <=8.0 error. Try to find <meta > tag with same
name.
+ LOG.debug("Header "+name+" not found, search in <meta>");
+ if(this._parsingStatus == Sarissa.PARSED_OK){
+ var metas = this.getElementsByTagName("meta");
+ for(var i = 0; i < metas.length;i++){
+ var meta = metas[i];
+ LOG.debug("Find <meta
name='"+meta.getAttribute('name')+"'
content='"+meta.getAttribute('content')+"'>");
+ if(meta.getAttribute("name") == name){
+ result = meta.getAttribute("content");
+ break;
+ }
+ }
+ }
+
+ }
+ return result;
+ },
+ /**
+ * get elements with elementname in responseXML or, if present - in element.
+ */
+ getElementsByTagName : function(elementname,element){
+ if(!element){
+ element = this._request.responseXML;
+ }
+ LOG.debug("search for elements by name '"+elementname+"'
"+" in element "+element.nodeName);
+ var elements;
+ try
+ {
+ elements = element.selectNodes(".//*[local-name()=\""+
+ elementname +"\"]");
+ LOG.debug("selectNodes found "+elements.length);
+ }
+ catch (ex) {
+ elements = element.getElementsByTagName(elementname);
+ LOG.debug("getElementsByTagName found "+elements.length);
+ }
+// return document.getElementsByTagName(tagName);
+// elements =
element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml",e...;
+// LOG.debug("getElementsByTagNameNS found "+elements.length);
+ return elements;
+ },
+ /**
+ * Find element in response by ID. Since in IE response not validated, use
selectSingleNode instead.
+ */
+ getElementById : function(id){
+ // first attempt - .getElementById.
+ var oDoc = this._request.responseXML;
+ if(typeof(oDoc.getElementById) != 'undefined') {
+ LOG.debug("call getElementById for id= "+id);
+ return oDoc.getElementById(id);
+ }
+ else if(typeof(oDoc.selectSingleNode) != "undefined") {
+ LOG.debug("call selectSingleNode for id= "+id);
+ return oDoc.selectSingleNode("//*[@id='"+id+"']"); /*
XPATH istead of ID */
+ }
+ // nodeFromID not worked since XML validation disabled by
+ // default for MS
+ else if(typeof(oDoc.nodeFromID) != "undefined") {
+ LOG.debug("call nodeFromID for id= "+id);
+ return oDoc.nodeFromID(id);
+ }
+ LOG.error("No functions for getElementById found ");
+ return null;
+
+ },
+
+ getJSON : function(id){
+ var data;
+ var dataElement = this.getElementById(id);
+ if(dataElement){
+ try {
+ data = Sarissa.getText(dataElement,true);
+ data = window.eval('('+data+')');
+ } catch(e){
+ LOG.error("Error on parsing JSON data "+e.message,data);
+ }
+ }
+ return data;
+ },
+
+ evalScripts : function(node){
+ var newscripts = this.getElementsByTagName("script",node);
+ LOG.debug("Scripts in updated part count : " + newscripts.length);
+ if( newscripts.length > 0 ){
+ window.setTimeout(function() {
+ for (var i = 0; i < newscripts.length; i++){
+ var newscript = Sarissa.getText( newscripts[i],true ) ; // TODO - Mozilla
disable innerHTML in XML page ..."";
+ try {
+ LOG.debug("Evaluate script replaced area in document: ",
newscript);
+ if (window.execScript) {
+ window.execScript( newscript );
+ } else {
+ window.eval(newscript);
+ }
+ } catch(e){
+ LOG.error("ERROR Evaluate script: Error name: " + e.name +
e.message?". Error message: "+e.message:"");
+ }
+ }
+ newscripts = null;
+ },50);
+ }
+
+ },
+ /**
+ * Update DOM element with given ID by element with same ID in parsed responseXML
+ */
+ updatePagePart : function(id){
+ var newnode = this.getElementById(id);
+ if( ! newnode ) { LOG.error("New node for ID "+id+" is not present in
response");return;}
+ var oldnode = window.document.getElementById(id);
+ if ( oldnode ) {
+ var anchor = oldnode.parentNode ;
+ // need to check for firstChild due to opera 8 bug with hasChildNodes
+ Sarissa.clearChildNodes(oldnode);
+ if(oldnode.outerHTML){
+ LOG.debug("Replace content of node by outerHTML()");
+ oldnode.outerHTML = new XMLSerializer().serializeToString(newnode);
+ } else {
+ var importednode ;
+ importednode = window.document.importNode(newnode, true);
+ LOG.debug("Replace content of node by replaceChild()");
+ anchor.replaceChild(importednode,oldnode);
+ }
+ // re-execute all script fragments in imported subtree...
+ // TODO - opera 8 run scripts at replace content stage.
+ if(!A4J.AJAX._scriptEvaluated){
+ this.evalScripts(newnode);
+ }
+ LOG.debug("Update part of page for Id: "+id + "
successful");
+ } else {
+ LOG.warn("Node for replace by response with id "+id+" not found in
document");
+ }
+
+ },
+
+ appendNewHeadElements : function(){
+ // Append scripts and styles to head, if not presented in page before.
+
this._appendNewElements("script","src",["type","language","charset"]);
+
this._appendNewElements("link","href",["type","rel","rev","media"]);
+ },
+
+ _appendNewElements : function(tag,href,attributes){
+ var newscripts = this.getElementsByTagName(tag);
+ var oldscripts = document.getElementsByTagName(tag);
+ var head =
document.getElementsByTagName("head")[0]||document.documentElement;
+ for(var i=0 ; i<newscripts.length;i++){
+ var element = newscripts[i];
+ var src = element.getAttribute(href);
+ if(src){
+ var exist = false;
+ LOG.debug("<"+tag+"> in response with
src="+src);
+ for(var j = 0 ; j < oldscripts.length; j++){
+ if(this._noSessionHref(src) ==
this._noSessionHref(oldscripts[j].getAttribute(href))){
+ LOG.debug("Such element exist in document");
+ exist = true;
+ break;
+ }
+ }
+ if(!exist){
+ // var script = window.document.importNode(element,true); //
+ var script = document.createElement(tag);
+ script.setAttribute(href,src);
+ for(var j = 0 ; j < attributes.length; j++){
+ this._copyAttribute(element,script,attributes[j]);
+ }
+ LOG.debug("append element to document");
+ head.appendChild(script);
+ }
+ }
+ }
+
+ },
+
+ _noSessionHref : function(href){
+ var sessionid = href.lastIndexOf(";jsessionid=");
+ var cref = href;;
+ if(sessionid>0){
+ cref = href.substring(0,sessionid);
+ var params = href.firstIndexOf("?");
+ if(params>sessionid){
+ cref=cref+href.substring(params);
+ }
+ }
+ return cref;
+ },
+
+ _copyAttribute : function(src,dst,attr){
+ var value = src.getAttribute(attr);
+ if(value){
+ dst.setAttribute(attr,value);
+ }
+ }
+
+};
+// eventsQueues for ajax submit events.
+A4J.AJAX._eventsQueues={};
+
+//Listeners should be notified
+A4J.AJAX.Listener = function(onafterajax){
+ this.onafterajax = onafterajax;
+};
+
+A4J.AJAX._listeners= [];
+A4J.AJAX.AddListener = function(listener){
+ A4J.AJAX._listeners.push(listener);
+};
+A4J.AJAX.removeListeners = function(listener){
+ A4J.AJAX._listeners = [];
+};
+// pollers timerId's
+A4J.AJAX._pollers = {};
+/*
+ *
+ *
+ */
+A4J.AJAX.Poll = function( containerId, form, options ) {
+ A4J.AJAX.StopPoll(options.pollId);
+ options.onerror = function(){
+ // For error, re-submit request.
+ A4J.AJAX.Poll(containerId,form,options);
+ };
+ A4J.AJAX._pollers[options.pollId] = window.setTimeout(function(){
+ A4J.AJAX._pollers[options.pollId]=undefined;
+ A4J.AJAX.SubmitRequest(containerId,form,null,options);
+ },options.pollinterval);
+};
+
+A4J.AJAX.StopPoll = function( Id ) {
+ if(A4J.AJAX._pollers[Id]){
+ window.clearTimeout(A4J.AJAX._pollers[Id]);
+ A4J.AJAX._pollers[Id] = undefined;
+ }
+};
+
+/*
+ *
+ *
+ */
+A4J.AJAX.Push = function( containerId, form, options ) {
+ A4J.AJAX.StopPush(options.pushId);
+ options.onerror = function(){
+ // For error, re-submit request.
+ A4J.AJAX.Push(containerId,form,options);
+ };
+ A4J.AJAX._pollers[options.pushId] = window.setTimeout(function(){
+ var request = new XMLHttpRequest();
+ request.onreadystatechange = function(){
+ if (request.readyState == 4 ) {
+ try {
+ if(request.status == 200){
+// A4J.AJAX._pollers[options.pushId]=undefined;
+ A4J.AJAX.SubmitRequest(containerId,form||options.dummyForm,null,options);
+ }
+ } catch(e){
+ // Network error.
+ }
+ // Re-send request.
+ A4J.AJAX.Push( containerId, form, options );
+ request=null;
+// A4J.AJAX._pollers[options.pushId] = window.setTimeout(function(){
+// A4J.AJAX.SendPush( request,options );
+// },options.pushinterval);
+ }
+ }
+ A4J.AJAX.SendPush( request,options );
+ },options.pushinterval);
+};
+
+A4J.AJAX.SendPush = function( request,options ) {
+ var url = options.pushUrl || options.actionUrl;
+ request.open('HEAD', url , true);
+ request.setRequestHeader( "Ajax-Push-Key", options.pushId);
+ if(options.timeout){
+ request.setRequestHeader( "Timeout", options.timeout);
+ }
+ request.send();
+}
+
+A4J.AJAX.StopPush = function( Id ) {
+ if(A4J.AJAX._pollers[Id]){
+ window.clearTimeout(A4J.AJAX._pollers[Id]);
+ A4J.AJAX._pollers[Id] = undefined;
+ }
+};
+
+
+
+A4J.AJAX.CloneObject = function( obj, noFunctions ) {
+ var cloned = {};
+ for( var n in obj ){
+ if(noFunctions && typeof(evt[prop]) == 'function'){
+ continue;
+ }
+ cloned[n]=obj[n];
+ }
+ return cloned;
+}
+
+
+A4J.AJAX.SubmitForm = function( containerId, form, options ) {
+ var opt = A4J.AJAX.CloneObject(options);
+ // Setup active control if form submitted by button.
+ if(A4J._formInput){
+ LOG.debug("Form submitted by button "+A4J._formInput.id);
+ opt.control = A4J._formInput;
+ A4J._formInput = null;
+ }
+ A4J.AJAX.Submit(containerId,form,null,opt);
+}
+
+// Submit or put in queue request. It not full queues - framework perform waiting only
one request to same queue, new events simple replace last.
+// If request for same queue already performed, replace with current parameters.
+A4J.AJAX.Submit = function( containerId, form, evt , options ) {
+ var domEvt;
+ evt = evt || window.event || null;
+ if(evt){
+ // Create copy of event object, since most of properties undefined outside of event
capture.
+ try {
+ domEvt = A4J.AJAX.CloneObject(evt,false);
+ } catch(e){
+ LOG.warn("Exception on clone event");
+ }
+ LOG.debug("Have Event "+domEvt+" with properties: target:
"+domEvt.target+", srcElement: "+domEvt.srcElement+", type:
"+domEvt.type);
+ }
+ if(options.eventsQueue){
+ var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
+ if( eventsQueue ) {
+ var eventsCount = eventsQueue.options.eventsCount||1;
+ eventsQueue.wait=true;
+ eventsQueue.containerId=containerId;
+ eventsQueue.form=form;
+ eventsQueue.domEvt=domEvt;
+ eventsQueue.options=options;
+ eventsQueue.options.eventsCount = eventsCount+1;
+ if(options.ignoreDupResponses && eventsQueue.request){
+ LOG.debug("Abort uncompleted request in queue
"+options.eventsQueue);
+ eventsQueue.request.abort();
+ eventsQueue.request=false;
+ eventsQueue.wait=false;
+ if( options.requestDelay ){
+ window.setTimeout(function() {
+ LOG.debug("End delay waiting, make request in queue
"+options.eventsQueue);
+ A4J.AJAX.SubmiteventsQueue(A4J.AJAX._eventsQueues[options.eventsQueue]);
+ },options.requestDelay);
+ LOG.debug("Create new waiting for request in queue
"+options.eventsQueue);
+ return;
+ }
+ } else {
+ LOG.debug("Put new event to queue "+options.eventsQueue);
+ return;
+ }
+ } else {
+ var queue = { wait : false, containerId : containerId , form : form, domEvt :
domEvt, options : options};
+ A4J.AJAX._eventsQueues[options.eventsQueue] = queue;
+ if( options.requestDelay ){
+ window.setTimeout(function() {
+ LOG.debug("End delay waiting, make request in queue
"+options.eventsQueue);
+ A4J.AJAX.SubmiteventsQueue(A4J.AJAX._eventsQueues[options.eventsQueue]);
+ },options.requestDelay);
+ LOG.debug("Event occurs, create waiting for request in queue
"+options.eventsQueue);
+ return;
+ }
+ }
+ }
+ A4J.AJAX.SubmitRequest( containerId, form, domEvt , options );
+};
+
+A4J.AJAX.SubmiteventsQueue = function( eventsQueue ) {
+ // Clear wait flag to avoid resend same request.
+ eventsQueue.wait=false;
+ A4J.AJAX.SubmitRequest( eventsQueue.containerId, eventsQueue.form ,eventsQueue.domEvt ,
eventsQueue.options );
+};
+ // Main request submitting functions.
+ // parameters :
+ // form - HtmlForm object for submit.
+ // control - form element, called request, or, clientID for JSF view.
+ // affected - Array of ID's for DOM Objects, updated after request. Override
+ // list of updated areas in response.
+ // statusID - DOM id request status tags.
+ // oncomplete - function for call after complete request.
+A4J.AJAX.SubmitRequest = function( containerId, formId ,domEvt , options ) {
+ // First - run onsubmit event for client-side validation.
+ LOG.debug("NEW AJAX REQUEST !!! with form :"+formId );
+// var form = A4J.AJAX.locateForm(event);
+ var form = window.document.getElementById(formId);
+ if( (!form || form.nodeName.toUpperCase() != "FORM") && domEvt ) {
+ var srcElement = domEvt.target||domEvt.srcElement||null;
+ if(srcElement){
+ form = A4J.AJAX.locateForm(srcElement);
+ };
+ };
+ // TODO - test for null of form object
+ if(form && form.onsubmit) {
+ LOG.debug("Form have onsubmit function, call it" );
+ if( form.onsubmit() == false ){
+ return false;
+ };
+ };
+ var tosend = new A4J.Query(containerId, form);
+ tosend.appendFormControls(options.single);
+ if(options.control){
+ tosend.appendControl(options.control,true);
+ };
+ if(options.parameters){
+ tosend.appendParameters(options.parameters);
+ };
+ if(options.eventsCount){
+ tosend.appendParameter("AJAX:EVENTS_COUNT",options.eventsCount);
+ };
+ if(options.actionUrl){
+ tosend.setActionUrl(options.actionUrl);
+ };
+ // build xxxHttpRequest. by Sarissa / JSHttpRequest class always defined.
+ var req = new A4J.AJAX.XMLHttpRequest(tosend);
+
+ req.options = options;
+ req.containerId = containerId;
+ req.domEvt = domEvt;
+ req.form = form;
+ if(options.timeout){
+ req.setRequestTimeout(options.timeout);
+ };
+
+ // Event handler for process response result.
+ req.onready = A4J.AJAX.processResponse;
+
+ if(options.onerror){
+ req._onerror = options.onerror;
+ } else if(typeof(A4J.AJAX.onError)== "function"){
+ req._onerror = A4J.AJAX.onError;
+ }
+ req.onfinish = A4J.AJAX.finishRequest;
+
+ A4J.AJAX.status(containerId,options.status,true);
+ req.send();
+ if(options.eventsQueue){
+ var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
+ if( eventsQueue ) {
+ eventsQueue.request=req;
+ }
+ }
+
+ return false;
+ };
+
+
+
+A4J.AJAX.processResponse = function(req) {
+ var options = req.options;
+ var ajaxResponse = req.getResponseHeader('Ajax-Response');
+ if( ajaxResponse != "true"){
+ // NO Ajax header - new page.
+ LOG.warn("No ajax response header ");
+ var loc = req.getResponseHeader("Location");
+ try{
+ if(ajaxResponse == 'redirect' && loc){
+ var expiredMsg = req.getResponseHeader('Ajax-Expired');
+ if(expiredMsg){
+ loc = A4J.AJAX.onExpired(loc,expiredMsg);
+ if(!loc){
+ return;
+ }
+ }
+ window.location = loc;
+ } else if(ajaxResponse == "reload"){
+ window.location.reload(true);
+ } else {
+ var isIE = _SARISSA_IS_IE;
+ // maksimkaszynski
+ //Prevent "Permission denied in IE7"
+ //Reset calling principal
+ if (isIE) {
+ var oldDocOpen = window.document.open;
+ window.document.open = function() {
+ oldDocOpen.apply(this, arguments);
+ }
+ }
+ // /maksimkaszynski
+ window.setTimeout(function() {
+ var isDocOpen=false;
+ try {
+ window.document.open(req.getContentType(),true);
+ isDocOpen=true;
+ window.document.write(req.getResponseText());
+ window.document.close();
+ if(isIE){
+ // For Ie , scripts on page not activated.
+ window.location.reload(false);
+ }
+ } catch(e) {
+ if(isDocOpen){
+ window.document.close();
+ }
+ // Firefox/Mozilla in XHTML case don't support document.write()
+// window.location =
"data:"+req.getContentType()+";charset=utf-8," +
encodeURIComponent(req.getResponseText())
+ // Use dom manipulation instead.
+ var oDomDoc = (new DOMParser()).parseFromString(req.getResponseText(),
"application/xhtml+xml");
+ var node = window.document.importNode(oDomDoc.documentElement, true);
+ window.document.replaceChild(node,window.document.documentElement);
+ // TODO - scripts reloading ?
+ }
+ },30);
+ }
+ } catch(e){
+ LOG.error("Error redirect to new location ");
+ }
+ } else {
+ if(req.getParserStatus() == Sarissa.PARSED_OK){
+ var idsFromResponse = req.getResponseHeader("Ajax-Update-Ids");
+ // 3 strategy for replace :
+ // if setted affected parameters - replace its
+ if( options.affected ) {
+ req.appendNewHeadElements();
+ for ( var k =0; k < options.affected.length ; k++ ) {
+ LOG.debug("Update page part from call parameter for ID " +
options.affected[k]);
+ req.updatePagePart(options.affected[k]);
+ };
+ // if resopnce contains element with ID "ajax:update" get id's from
+ // child text element . like :
+ // <div id="ajax:update" style="display none" >
+ // <span>_id1:1234</span>
+ // .........
+ // </div>
+ //
+ } else if( idsFromResponse != "" ) {
+ LOG.debug("Update page by list of rendered areas from response " +
idsFromResponse );
+ // Append scripts and styles to head, if not presented in page before.
+ req.appendNewHeadElements();
+ var childs = idsFromResponse.split(",");
+ for ( var k=0 ; k < childs.length ; k++ ) {
+ var id = childs[k];
+ LOG.debug("Attempt to update part of page for Id: "+id);
+ if ( id ) {req.updatePagePart(id);};
+ };
+ } else {
+ // if none of above - error ?
+ // A4J.AJAX.replace(form.id,A4J.AJAX.findElement(form.id,xmlDoc));
+ LOG.warn("No information in response about elements to replace");
+ }
+ // Replace client-side hidden inputs for JSF View state.
+ var idsSpan = req.getElementById("ajax-update-ids");
+ LOG.debug("Hidden JSF state fields: "+idsSpan);
+ if(idsSpan != null){
+ // For a portal case, replace content in the current window only.
+ var namespace = options.parameters['org.ajax4jsf.portlet.NAMESPACE'];
+ LOG.debug("Namespace for hidden view-state input fields is
"+namespace);
+ var anchor =
namespace?window.document.getElementById(namespace):window.document;
+ var inputs = anchor.getElementsByTagName("input");
+ var newinputs = req.getElementsByTagName("input",idsSpan);
+ A4J.AJAX.replaceViewState(inputs,newinputs);
+ // For any cases, new state can be in uppercase element
+ newinputs = req.getElementsByTagName("INPUT",idsSpan);
+ A4J.AJAX.replaceViewState(inputs,newinputs);
+ }
+ // Process listeners.
+ for(var li = 0; li < A4J.AJAX._listeners.length; li++){
+ var listener = A4J.AJAX._listeners[li];
+ if(listener.onafterajax){
+ // Evaluate data as JSON String.
+ var data = req.getJSON('_ajax:data');
+ listener.onafterajax(req,req.domEvt,data);
+ }
+ }
+ // Set focus, if nessesary.
+ var focusId = req.getJSON("_A4J.AJAX.focus");
+ if(focusId){
+ LOG.debug("focus must be set to control "+focusId);
+ var focusElement=false;
+ if(req.form){
+ // Attempt to get form control for name. By Richfaces naming convensions,
+ // complex component must set clientId as DOM id for a root element ,
+ // and as input element name.
+ focusElement = req.form.elements[focusId];
+ }
+ if(!focusElement){
+ // If not found as control element, search in DOM.
+ LOG.debug("No control element "+focusId+" in submitted
form");
+ focusElement = document.getElementById(focusId);
+ }
+ if(focusElement){
+ LOG.debug("Set focus to control ");
+ focusElement.focus();
+ } else {
+ LOG.warn("Element for set focus not found");
+ }
+ } else {
+ LOG.debug("No focus information in response");
+ }
+ } else {
+ // No response XML
+ LOG.error( "Error parsing XML" );
+ LOG.error("Parse Error: " + req.getParserStatus());
+ }
+ }
+ };
+
+A4J.AJAX.onExpired = function(loc,expiredMsg){
+ if(window.confirm(expiredMsg)){
+ return loc;
+ } else {
+ return undefined;
+ }
+};
+
+
+A4J.AJAX.replaceViewState = function(inputs,newinputs){
+ LOG.debug("Replace value for inputs: "+inputs.length + " by
new values: "+ newinputs.length);
+ if( (newinputs.length > 0) && (inputs.length > 0) ){
+ for(var i = 0 ; i < newinputs.length; i++){
+ var newinput = newinputs[i];
+ LOG.debug("Input in response:
"+newinput.getAttribute("name"));
+ for(var j = 0 ; j < inputs.length; j++){
+ var input = inputs[j];
+ if(input.name == newinput.getAttribute("name")){
+ LOG.debug("Found same input on page with type: "+input.type);
+ input.value = newinput.getAttribute("value");
+ }
+ }
+ }
+ }
+
+};
+/**
+ *
+ */
+A4J.AJAX.finishRequest = function(req){
+ var options = req.options;
+ // mark status object ( if any ) for complete request ;
+ A4J.AJAX.status(req.containerId,options.status,false);
+ // we can set listener for complete request - for example,
+ // it can shedule next request for update page.
+ if(options.oncomplete){
+ LOG.debug( "Call request oncomplete function after processing updates"
);
+ window.setTimeout(function(){
+ options.oncomplete(req,req.domEvt,req.getJSON('_ajax:data'));},
+ 50);
+
+ }
+ // If we have events in queue - send next request.
+ if(options.eventsQueue){
+ var eventsQueue = A4J.AJAX._eventsQueues[options.eventsQueue];
+ if( eventsQueue ) {
+ A4J.AJAX._eventsQueues[options.eventsQueue]=false;
+ if(eventsQueue.wait){
+ LOG.debug("Queue not empty, execute next request in queue
"+options.eventsQueue);
+ A4J.AJAX.SubmiteventsQueue(eventsQueue);
+ }
+ }
+ }
+ };
+
+ // Locate enclosing form for object.
+A4J.AJAX.locateForm = function(obj){
+
+ var parent = obj;
+ while(parent && parent.nodeName.toLowerCase() != 'form'){
+ parent = parent.parentNode;
+ };
+ return parent;
+
+ };
+
+A4J.AJAX.getElementById = function(id,options){
+ var namespace = options['org.ajax4jsf.portlet.NAMESPACE'];
+ var anchor = namespace?window.document.getElementById(namespace):window.document;
+ var element;
+ if(anchor){
+ element = anchor.getElementById(id);
+ } else {
+ LOG.error("No root element for portlet namespace "+namespace+" on
page");
+ }
+ return element;
+}
+
+ // hash for requests count for all ID's
+A4J.AJAX._requestsCounts = {};
+ // Change status object on start/stop request.
+ // on start, document object with targetID+".start" make visible,
+ // document object with targetID+".stop" make invisible.
+ // on stop - inverse.
+A4J.AJAX.status = function(regionID,targetID,start){
+ try {
+ var elem;
+ targetID = targetID || regionID +":status";
+
A4J.AJAX._requestsCounts[targetID]=(A4J.AJAX._requestsCounts[targetID]||0)+(start?1:-1);
+ if(A4J.AJAX._requestsCounts[targetID]>0){
+ elem = document.getElementById(targetID+".stop");
+ if(elem){elem.style.display="none";}
+ elem = document.getElementById(targetID+".start");
+ if(elem){
+ elem.style.display="";
+ if(typeof(elem.onstart) == 'function'){
+ elem.onstart();
+ }
+ }
+ }else{
+ elem = document.getElementById(targetID+".start");
+ if(elem){elem.style.display="none";}
+ elem = document.getElementById(targetID+".stop");
+ if(elem){
+ elem.style.display="";
+ if(typeof(elem.onstop) == 'function'){
+ elem.onstop();
+ }
+ }
+ }
+ } catch(e){
+ LOG.error("Exception on status change: ");
+ }
+};
+
+
+
+
+// Class for build query string.
+A4J.Query = function(containerId,form){
+ // For detect AJAX Request.
+ this._query = {AJAXREQUEST : containerId};
+ this._oldSubmit = null ;
+ this._form = form ;
+ this._actionUrl = ( this._form.action)?this._form.action:this._form;
+ };
+
+A4J.Query.prototype = {
+ _form : null,
+ _actionUrl : null,
+ _ext : "",
+ _query : {},
+ _oldSubmit : null,
+ // init at loading time - script can change location at run time ? ...
+ _pageBase : window.location.protocol+"//"+window.location.host,
+ // hash for control elements query string functions
+
+ hidden : function(control){
+ this._value_query(control);
+ // TODO - configurable mask for hidden command scripts.
+ if( (control.name.length > 4) &&
(control.name.lastIndexOf("_idcl") == (control.name.length-5)) ){
+ control.value="";
+ // MYfaces version ...
+ } else if( (control.name.length > 12) &&
(control.name.lastIndexOf("_link_hidden_") == (control.name.length-13)) ){
+ control.value="";
+ }
+ },
+
+ text : function(control){
+ this._value_query(control);
+ },
+
+ textarea : function(control){
+ this._value_query(control);
+ },
+
+ 'select-one' : function(control){
+ // If none options selected, don't include parameter.
+ if (control.selectedIndex != -1) {
+ this._value_query(control);
+ }
+// for( var i =0; i< control.childNodes.length; i++ ){
+// var child=control.childNodes[i];
+// if( child.selected ){
+// this._value_query(control);
+// break;
+// }
+// }
+ },
+
+ password : function(control){
+ this._value_query(control);
+ },
+
+ file : function(control){
+ this._value_query(control);
+ },
+
+ radio : function(control){
+ this._check_query(control);
+ },
+
+ checkbox : function(control){
+ this._check_query(control);
+ },
+
+
+ 'select-multiple' : function(control){
+ var cname = control.name;
+ var childs = control.childNodes;
+ for( var i=0 ;i< childs.length;i++ ){
+ var child=childs[i];
+ if( child.tagName == 'OPTGROUP' ){
+ var options = child.childNodes;
+ for(var j=0; j < options.length; j++){
+ this._addOption(cname, options[j]);
+ }
+ } else {
+ this._addOption(cname, child);
+ }
+ }
+ },
+
+ _addOption : function(cname,option){
+ if ( option.selected ){
+ if( ! this._query[cname] ){
+ this._query[cname]=[];
+ }
+ this._query[cname][this._query[cname].length]=option.value;
+ }
+
+ },
+// command inputs
+
+ image : function( control, action ){
+ if(action) this._value_query(control);
+ },
+ button : function( control, action ){
+ if(action) this._value_query(control);
+ },
+
+ submit : function( control, action ){
+ if(action) {
+ this._value_query(control);
+ }
+ },
+
+ // Anchor link pseudo-control.
+ link : function(control, action ){
+ if(action) {
+ this._value_query(control);
+ if(control.parameters){
+ this.appendParameters(control.parameters);
+ }
+ }
+ },
+
+ // same as link, but have additional field - control, for input submit.
+ input : function(control, action ){
+ if(action) {
+ this.link(control, action );
+ // append original control.
+ if( control.control ) {
+ this.appendControl(control.control,action);
+ }
+ }
+ },
+
+ // Append one control to query.
+ appendControl : function(control,action){
+ if( this[control.type] ) {
+ this[control.type](control,action);
+ } else {
+ this._appendById(control.id||control);
+ }
+
+ },
+
+ // Append all non-hidden controls from form to query.
+ appendFormControls : function(hiddenOnly){
+ try {
+ var elems = this._form.elements;
+ if(elems){
+ var k = 0;
+ for ( k=0;k<elems.length;k++ ) {
+ var element=elems[k];
+ try {
+ if( !hiddenOnly || element.type == "hidden") {
+ this.appendControl(element,false) ;
+ }
+ } catch( ee ) {
+ LOG.error("exception in building query ( append form control ) " +
ee );
+ }
+ }
+ }
+ } catch(e) {
+ LOG.warn("Error with append form controls to query "+e)
+ }
+ },
+
+ // append map of parameters to query.
+ appendParameters : function(parameters){
+ for( k in parameters ){
+ if(typeof Object.prototype[k] == 'undefined'){
+ LOG.debug( "parameter " + k + " with value
"+parameters[k]);
+ this.appendParameter(k,parameters[k]);
+ }
+ }
+ },
+
+ setActionUrl : function(actionUrl){
+ this._actionUrl = actionUrl;
+ },
+// Return action URL ( append extention, if present )
+ getActionUrl : function( ext ) {
+ var actionUrl = this._actionUrl ;
+ var ask = actionUrl.indexOf('?');
+ // create absolute reference - for Firefox XMLHttpRequest base url can vary
+ if( actionUrl.substring(0,1) == '/' ) {
+ actionUrl = this._pageBase+actionUrl;
+ }
+ if ( ! ext ) ext = this._ext ;
+ if( ask >=0 )
+ {
+ return actionUrl.substring(0,ask) + ext + actionUrl.substring(ask);
+ }
+ else return actionUrl + ext;
+ },
+
+
+// Build query string for send to server.
+ getQueryString : function() {
+ var qs = "";
+ var iname ;
+ for ( var k in this._query ){
+ if(typeof Object.prototype[k] == 'undefined'){
+ iname = this._query[k];
+ if( iname instanceof Object ){
+ for ( var l=0; l< iname.length; l++ ) {
+ qs += this._encode(k) + "=" + this._encode(iname[l]) +
"&";
+ }
+ } else {
+ qs += this._encode(k) + "=" + this._encode(iname) + "&";
+ }
+ }
+ }
+ LOG.debug("QueryString: "+qs);
+ return qs;
+ },
+ // private methods
+
+ _appendById : function( id ) {
+ this.appendParameter(this._form.id + "_link_hidden_", id);
+ // JSF-ri version ...
+ // this._query[this._form.id + "_idcl"]=id;
+ },
+
+
+ _value_query : function(control){
+ LOG.debug("Append "+control.type+" control "+control.name+"
with value ["+control.value+"] and value attribute
["+control.getAttribute('value')+"]");
+ if(null != control.value){
+ this.appendParameter(control.name, control.value);
+ }
+ },
+
+ _check_query : function(control){
+ if( control.checked ) {
+ this.appendParameter(control.name, control.value?control.value:"on");
+ }
+ },
+
+ // Append parameter to query. if name exist, append to array of parameters
+ appendParameter: function(cname,value){
+ if( ! this._query[cname] ){
+ this._query[cname]=value;
+ return;
+ } else if( !(this._query[cname] instanceof Object) ){
+ this._query[cname] = [this._query[cname]];
+ }
+ this._query[cname][this._query[cname].length]=value;
+ },
+
+ // Encode data string for request string
+ _encode : function(string) {
+ try {
+ return encodeURIComponent(string);
+ } catch(e) {
+ var str = escape(string);
+ // escape don't encode +. but form replace ' ' in fields by
'+'
+ return str.split('+').join('%2B');
+ }
+ }
+
+
+ }
+
+// Test for re-evaluate Scripts in updated part. Opera & Safari do it.
+A4J.AJAX._scriptEvaluated=false;
+if (!document.all || window.opera){
+ setTimeout(function(){
+ try{
+ // Simulate same calls as on XmlHttp
+ var oDomDoc = Sarissa.getDomDocument();
+ var _span = document.createElement("span");
+ document.documentElement.appendChild(_span);
+ // If script evaluated with used replace method, variable will be set to true
+ var xmlString = "<html
xmlns='http://www.w3.org/1999/xhtml'><sc"+"ript&g...;
+ oDomDoc = (new DOMParser()).parseFromString(xmlString, "text/xml");
+ var _script=oDomDoc.getElementsByTagName("script")[0];
+ if(_span.outerHTML){
+ _span.outerHTML = new XMLSerializer().serializeToString(_script);
+ } else {
+ var importednode ;
+ importednode = window.document.importNode(_script, true);
+ document.documentElement.replaceChild(importednode,_span);
+ }
+
+ } catch(e){ /* Mozilla in XHTML mode not have innerHTML */ };
+ },50);
+}
Copied: tags/1_1_1_rc1/samples/seamIntegration/.exadelproject (from rev 164,
trunk/samples/seamIntegration/.exadelproject)
===================================================================
--- tags/1_1_1_rc1/samples/seamIntegration/.exadelproject (rev 0)
+++ tags/1_1_1_rc1/samples/seamIntegration/.exadelproject 2007-05-04 01:10:03 UTC (rev
168)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FILESYSTEMS APPLICATION_NAME="seamIntegration"
ENTITY="FileSystems"
+ VERSION="8.0.4" WORKSPACE_HOME="./src/main/webapp/WEB-INF">
+ <FILESYSTEM ENTITY="FileSystemFolder"
LOCATION="%exadel.workspace%" NAME="WEB-INF"/>
+ <FILESYSTEM ENTITY="FileSystemFolder" INFO="Content-Type=Web"
+ LOCATION="%exadel.workspace%/.." NAME="WEB-ROOT"/>
+ <FILESYSTEM ENTITY="FileSystemFolder"
+ LOCATION="%exadel.workspace%/../../java" NAME="src"/>
+ <FILESYSTEM ENTITY="FileSystemFolder"
+ LOCATION="%exadel.workspace%/../../resources" NAME="src2"/>
+ <FILESYSTEM ENTITY="FileSystemFolder"
+ LOCATION="%exadel.workspace%/../../../test/java" NAME="src3"/>
+ <FILESYSTEM ENTITY="FileSystemFolder"
+ LOCATION="%exadel.workspace%/../../../../target/classes"
NAME="classes"/>
+ <FILESYSTEM ENTITY="FileSystemFolder"
+ LOCATION="%exadel.eclipse.project%" NAME="seamIntegration"/>
+ <WEB ENTITY="ExadelWeb" MODEL_PATH="/web.xml"
SERVLET_VERSION="2.4">
+ <MODULE ENTITY="WebJSFModule" ROOT="WEB-ROOT"
SRC="src,src2,src3" URI="/WEB-INF/faces-config.xml"/>
+ </WEB>
+</FILESYSTEMS>
Copied: tags/1_1_1_rc1/samples/useCases/src/main/java/control (from rev 167,
trunk/samples/useCases/src/main/java/control)
Copied: tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/A4jTestBean.java (from
rev 164, trunk/samples/useCases/src/main/java/org/ajax4jsf/A4jTestBean.java)
===================================================================
--- tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/A4jTestBean.java
(rev 0)
+++ tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/A4jTestBean.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,45 @@
+package org.ajax4jsf;
+
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+public class A4jTestBean {
+
+ private String param = "Not set yet";
+ private boolean checked;
+
+ public String getParam() {
+ return param;
+ }
+
+ public void setParam(String param) {
+ this.param = param;
+ }
+
+ private void checkMap() {
+ Map<String, String> params =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ for (String key : params.keySet()) {
+ System.out.println(key + "=" + params.get(key));
+ }
+ }
+
+ public void perform(ActionEvent actionEvent) {
+ System.out.println("A4jTestBean.perform(ActionEvent) = " + param);
+ checkMap();
+ }
+
+ public void perform() {
+ System.out.println("A4jTestBean.perform() = " + param);
+ checkMap();
+ }
+
+ public boolean isChecked() {
+ return checked;
+ }
+
+ public void setChecked(boolean checked) {
+ this.checked = checked;
+ }
+}
Deleted: tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/Bean.java
===================================================================
--- trunk/samples/useCases/src/main/java/org/ajax4jsf/Bean.java 2007-05-02 17:40:09 UTC
(rev 158)
+++ tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/Bean.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -1,104 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf;
-
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * @author $Autor$
- *
- */
-public class Bean {
-
- private java.lang.String text;
-
- private String[] array = {"one]","two]]>"};
-
- private String[][] array2 =
{{"one","two"},{"three","four"}};
-
- public java.lang.String getText() {
- return text;
- }
-
- public void setText(java.lang.String text) {
- this.text = text;
- }
-
- public String ok(){
- System.out.println("Button pressed");
- return null;
- }
-
- public String setCookie() {
- ExternalContext externalContext =
FacesContext.getCurrentInstance().getExternalContext();
- HttpServletResponse response = (HttpServletResponse)
externalContext.getResponse();
- Cookie cookie = new Cookie("test", "Setted at time
"+System.currentTimeMillis());
- cookie.setMaxAge(60 * 60 * 24 * 365);
- response.addCookie(cookie);
- return "verify_cookie";
- }
-
- public String getTestCookie(){
- ExternalContext externalContext =
FacesContext.getCurrentInstance().getExternalContext();
- HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
- Cookie[] cookies = request.getCookies();
- for (int i = 0; i < cookies.length; i++) {
- if("test".equals(cookies[i].getName())){
- return cookies[i].getValue();
- }
- }
- return null;
- }
-
- /**
- * @return the array
- */
- public String[] getArray() {
- return array;
- }
-
- /**
- * @param array the array to set
- */
- public void setArray(String[] array) {
- this.array = array;
- }
-
- /**
- * @return the array2
- */
- public String[][] getArray2() {
- return array2;
- }
-
- /**
- * @param array2 the array2 to set
- */
- public void setArray2(String[][] array2) {
- this.array2 = array2;
- }
-
-}
\ No newline at end of file
Copied: tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/Bean.java (from rev
164, trunk/samples/useCases/src/main/java/org/ajax4jsf/Bean.java)
===================================================================
--- tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/Bean.java
(rev 0)
+++ tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/Bean.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,153 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ValueChangeEvent;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author $Autor$
+ *
+ */
+public class Bean {
+
+ private java.lang.String text;
+
+ private String text2;
+
+ private String[] array = {"one]","two]]>"};
+
+ private String[][] array2 =
{{"one","two"},{"three","four"}};
+
+ public java.lang.String getText() {
+ return text;
+ }
+
+ public void setText(java.lang.String text) {
+ this.text = text;
+ }
+
+ public String ok(){
+ System.out.println("Button pressed");
+ return null;
+ }
+
+ public String setCookie() {
+ ExternalContext externalContext =
FacesContext.getCurrentInstance().getExternalContext();
+ HttpServletResponse response = (HttpServletResponse)
externalContext.getResponse();
+ Cookie cookie = new Cookie("test", "Setted at time
"+System.currentTimeMillis());
+ cookie.setMaxAge(60 * 60 * 24 * 365);
+ response.addCookie(cookie);
+ return "verify_cookie";
+ }
+
+ public String getTestCookie(){
+ ExternalContext externalContext =
FacesContext.getCurrentInstance().getExternalContext();
+ HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
+ Cookie[] cookies = request.getCookies();
+ for (int i = 0; i < cookies.length; i++) {
+ if("test".equals(cookies[i].getName())){
+ return cookies[i].getValue();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return the array
+ */
+ public String[] getArray() {
+ return array;
+ }
+
+ /**
+ * @param array the array to set
+ */
+ public void setArray(String[] array) {
+ this.array = array;
+ }
+
+ /**
+ * @return the array2
+ */
+ public String[][] getArray2() {
+ return array2;
+ }
+
+ /**
+ * @param array2 the array2 to set
+ */
+ public void setArray2(String[][] array2) {
+ this.array2 = array2;
+ }
+
+ /**
+ * @return the text2
+ */
+ public String getText2() {
+ return text2;
+ }
+
+ /**
+ * @param text2 the text2 to set
+ */
+ public void setText2(String test2) {
+ this.text2 = test2;
+ }
+
+ public void validate(FacesContext context, UIComponent input,Object newValue) {
+ FacesMessage msg = new FacesMessage("#{bean.validate} called");
+ context.addMessage(input.getClientId(context), msg);
+ System.out.println("validate");
+ }
+
+ public void onChange(ValueChangeEvent event) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ UIComponent input = event.getComponent();
+ FacesMessage msg = new FacesMessage("#{bean.onChange} called");
+ context.addMessage(input.getClientId(context), msg);
+ System.out.println("onChange");
+
+ }
+
+ public void validate2(FacesContext context, UIComponent input,Object newValue) {
+ FacesMessage msg = new FacesMessage("#{bean.validate2} called");
+ context.addMessage(input.getClientId(context), msg);
+ System.out.println("validate2");
+
+ }
+
+ public void onChange2(ValueChangeEvent event) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ UIComponent input = event.getComponent();
+ FacesMessage msg = new FacesMessage("#{bean.onChange2} called");
+ context.addMessage(input.getClientId(context), msg);
+ System.out.println("onChange2");
+
+ }
+}
\ No newline at end of file
Copied: tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/MessageBean.java (from
rev 165, trunk/samples/useCases/src/main/java/org/ajax4jsf/MessageBean.java)
===================================================================
--- tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/MessageBean.java
(rev 0)
+++ tags/1_1_1_rc1/samples/useCases/src/main/java/org/ajax4jsf/MessageBean.java 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,102 @@
+package org.ajax4jsf;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.EventListener;
+import java.util.EventObject;
+import java.util.List;
+
+import org.ajax4jsf.ajax.PushEventListener;
+
+public class MessageBean implements Runnable {
+
+ private String result;
+
+ private boolean running = true;
+
+ private PushEventListener listener;
+
+ private List messages = new ArrayList(10);
+
+ private int counter = 0;
+
+ public MessageBean() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @return the result
+ */
+ public String getResult() {
+ return result;
+ }
+
+ /**
+ * @param result
+ * the result to set
+ */
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+ public void addListener(EventListener listener) {
+ synchronized (listener) {
+ if (this.listener != listener) {
+ this.listener = (PushEventListener) listener;
+ Thread th = new Thread(this);
+ th.start();
+
+ }
+ }
+ }
+
+ public void run() {
+ try {
+ while (isRunning()) {
+ Thread.sleep(10000);
+ Date current = new Date(System.currentTimeMillis());
+ if(messages.size()>=10){
+ messages.remove(0);
+ }
+ messages.add(messages.size(),String.valueOf(counter++)+" at
"+current.toString());
+ System.out.println("event occurs");
+ synchronized (listener) {
+ listener.onEvent(new EventObject(this));
+ }
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * @return the running
+ */
+ public synchronized boolean isRunning() {
+ return running;
+ }
+
+ /**
+ * @param running
+ * the running to set
+ */
+ public synchronized void setRunning(boolean running) {
+ this.running = running;
+ }
+
+ /**
+ * @return the messages
+ */
+ public List getMessages() {
+ return messages;
+ }
+
+ /**
+ * @param messages the messages to set
+ */
+ public void setMessages(List messages) {
+ this.messages = messages;
+ }
+
+}
Deleted: tags/1_1_1_rc1/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml 2007-05-02 17:40:09
UTC (rev 158)
+++ tags/1_1_1_rc1/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml 2007-05-04
01:10:03 UTC (rev 168)
@@ -1,27 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces
Config 1.1//EN"
-
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
-<faces-config>
- <managed-bean>
- <managed-bean-name>bean</managed-bean-name>
- <managed-bean-class>org.ajax4jsf.Bean</managed-bean-class>
- <managed-bean-scope>request</managed-bean-scope>
- <managed-property>
- <property-name>text</property-name>
- <property-class>java.lang.String</property-class>
- <null-value/>
- </managed-property>
- </managed-bean>
- <managed-bean>
- <managed-bean-name>repeatData</managed-bean-name>
- <managed-bean-class>org.ajax4jsf.RepeatData</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
- </managed-bean>
- <navigation-rule>
- <navigation-case>
- <from-outcome>verify_cookie</from-outcome>
- <to-view-id>/pages/testCookie.xhtml</to-view-id>
- <redirect/>
- </navigation-case>
- </navigation-rule>
-</faces-config>
Copied: tags/1_1_1_rc1/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml (from rev
167, trunk/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml)
===================================================================
--- tags/1_1_1_rc1/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml
(rev 0)
+++ tags/1_1_1_rc1/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces
Config 1.1//EN"
+
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+<faces-config>
+ <managed-bean>
+ <managed-bean-name>bean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.Bean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ <managed-property>
+ <property-name>text</property-name>
+ <property-class>java.lang.String</property-class>
+ <null-value/>
+ </managed-property>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>repeatData</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.RepeatData</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>a4jTestBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.A4jTestBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>messageBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.MessageBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>dataManager</managed-bean-name>
+
<managed-bean-class>control.test.ControlBackingBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+ <navigation-rule>
+ <navigation-case>
+ <from-outcome>verify_cookie</from-outcome>
+ <to-view-id>/pages/testCookie.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+ </navigation-rule>
+</faces-config>
Copied: tags/1_1_1_rc1/samples/useCases/src/main/webapp/css (from rev 167,
trunk/samples/useCases/src/main/webapp/css)
Copied: tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/actionparam.xhtml (from rev
164, trunk/samples/useCases/src/main/webapp/pages/actionparam.xhtml)
===================================================================
--- tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/actionparam.xhtml
(rev 0)
+++ tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/actionparam.xhtml 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,36 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
+<body>
+<a4j:outputPanel id="messages">
+ <h:messages />
+</a4j:outputPanel>
+<h:form id="testForm">
+ <h:selectBooleanCheckbox value="#{a4jTestBean.checked}">
+ <a4j:support event="onchange"
actionListener="#{a4jTestBean.perform}"
+ reRender="output, messages">
+ <a4j:actionparam name="param" value="Checkbox clicked"
+ assignTo="#{a4jTestBean.param}" />
+ </a4j:support>
+ </h:selectBooleanCheckbox>
+ <br />
+ <a4j:commandButton limitToList="true" reRender="output,
messages"
+ actionListener="#{a4jTestBean.perform}"
value="a4j:commandButton">
+ <a4j:actionparam name="param" value="Command Button clicked"
+ assignTo="#{a4jTestBean.param}" />
+ </a4j:commandButton>
+ <br />
+ <a4j:outputPanel id="output">
+ <h:outputText value="a4jTestBean.param:
#{a4jTestBean.param}"/>
+ <h:outputText value=" Request parameter 'param':
#{params.param}"/>
+ </a4j:outputPanel>
+ <br />
+ <h:commandButton action="#{a4jTestBean.perform}"
+ value="h:commandButton" />
+</h:form>
+<a4j:log popup="false"></a4j:log>
+</body>
+</html>
Copied: tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/ajaxSingle.xhtml (from rev
164, trunk/samples/useCases/src/main/webapp/pages/ajaxSingle.xhtml)
===================================================================
--- tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/ajaxSingle.xhtml
(rev 0)
+++ tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/ajaxSingle.xhtml 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+
xmlns:c="http://java.sun.com/jsp/jstl/core">
+<f:view>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:inputText id="text" value="#{bean.text}"
+ validator="#{bean.validate}"
valueChangeListener="#{bean.onChange}">
+ <a4j:support event="onkeyup"
ajaxSingle="true"></a4j:support>
+ </h:inputText>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:outputText value="#{bean.text}"></h:outputText>
+ <h:message for="text"></h:message>
+ </a4j:outputPanel>
+ <h:inputText id="text2" value="#{bean.text2}"
+ validator="#{bean.validate2}"
+ valueChangeListener="#{bean.onChange2}">
+ <a4j:support event="onkeyup"
ajaxSingle="true"></a4j:support>
+ </h:inputText>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:outputText value="#{bean.text2}"></h:outputText>
+ <h:message for="text2"></h:message>
+ </a4j:outputPanel>
+ </h:panelGrid>
+ <h2>Ajax support with 'ajaxSingle="true"' in
a4j:repeat</h2>
+ <ul>
+ <a4j:repeat value="#{repeatData.data}" var="row">
+ <li><h:inputText id="repeattext" value="#{row.text}"
+ validator="#{bean.validate}"
valueChangeListener="#{bean.onChange}">
+ <a4j:support event="onkeyup"
ajaxSingle="true"></a4j:support>
+ </h:inputText> <a4j:outputPanel ajaxRendered="true">
+ <h:outputText value="#{row.text}"></h:outputText>
+ <h:message for="repeattext"></h:message>
+ </a4j:outputPanel></li>
+ </a4j:repeat>
+ </ul>
+ <h2>Ajax support with 'ajaxSingle="true"' in
h:dataTeble</h2>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:dataTable value="#{repeatData.data}" var="row"
border="1" id="table">
+ <h:column>
+ <h:inputText id="tabletext" value="#{row.text}"
+ validator="#{bean.validate}"
valueChangeListener="#{bean.onChange}">
+ <a4j:support event="onkeyup" ajaxSingle="true"
focus="tabletext"></a4j:support>
+ </h:inputText>
+ </h:column>
+ <h:column>
+ <h:outputText value="#{row.text}"></h:outputText>
+ <h:message for="tabletext"></h:message>
+ </h:column>
+ </h:dataTable>
+ </a4j:outputPanel>
+ <a4j:commandButton value="Ajax Button"></a4j:commandButton>
+ <a4j:commandButton value="Ajax Single Button"
ajaxSingle="true"></a4j:commandButton>
+ </h:form>
+ <a4j:log hotkey="M"></a4j:log>
+</f:view>
+</html>
Copied: tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/controls.jsp (from rev 167,
trunk/samples/useCases/src/main/webapp/pages/controls.jsp)
===================================================================
--- tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/controls.jsp
(rev 0)
+++ tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/controls.jsp 2007-05-04 01:10:03
UTC (rev 168)
@@ -0,0 +1,33 @@
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+<%@ taglib
uri="https://ajax4jsf.dev.java.net/ajax"
prefix="a4j"%>
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
+<f:view>
+ <html
xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
+ <a4j:loadStyle src="/css/global.css"/>
+ </head>
+ <body>
+ <a4j:form id="headForm">
+ <div id="infoBarContainer">
+ <div id="infoBarContent">
+ <a4j:outputPanel id="companyOutputPanel"
layout="inline" styleClass="linePanel">
+ <a4j:commandLink id="companyCommandLink"
value="#{dataManager.selectedCompany.desc}"
action="#{dataManager.commandAction}"
actionListener="#{dataManager.commandActionListener}"
reRender="selectPanel" />
+ </a4j:outputPanel>
+ <a4j:outputPanel id="agencyOutputPanel"
layout="inline" styleClass="linePanel">
+ <a4j:commandLink id="agencyCommandLink"
value="#{dataManager.selectedAgency.desc}"
action="#{dataManager.commandAction}"
actionListener="#{dataManager.commandActionListener}"
reRender="selectPanel" />
+ </a4j:outputPanel>
+ </div>
+ </div>
+ <a4j:outputPanel id="selectPanel" layout="block"
style="float:left;margin-top:5px;margin-left:5px;width:200px;">
+ <a4j:repeat id="selectDataList"
binding="#{dataManager.selectDataList}"
value="#{dataManager.selectData}" var="item"
ajaxKeys="#{dataManager.keys}">
+ <a4j:commandLink id="selectCommandLink"
value="#{item.desc}" action="#{dataManager.selectAction}"
actionListener="#{dataManager.selectActionListener}"
reRender="companyOutputPanel,agencyOutputPanel" style="display:block"
/>
+ </a4j:repeat>
+ </a4j:outputPanel>
+ </a4j:form>
+ </body>
+ </html>
+</f:view>
Copied: tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/controls.xhtml (from rev
167, trunk/samples/useCases/src/main/webapp/pages/controls.xhtml)
===================================================================
--- tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/controls.xhtml
(rev 0)
+++ tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/controls.xhtml 2007-05-04
01:10:03 UTC (rev 168)
@@ -0,0 +1,48 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+
xmlns:c="http://java.sun.com/jsp/jstl/core">
+<f:view>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
+ <a4j:loadStyle src="/css/global.css" />
+ </head>
+ <body>
+ <a4j:form id="headForm">
+ <div id="infoBarContainer">
+ <div id="infoBarContent"><a4j:outputPanel
+ id="companyOutputPanel" layout="inline"
styleClass="linePanel">
+ <a4j:commandLink id="companyCommandLink"
+ value="#{dataManager.selectedCompany.desc}"
+ action="#{dataManager.commandAction}"
+ actionListener="#{dataManager.commandActionListener}"
+ reRender="selectPanel" />
+ </a4j:outputPanel> <a4j:outputPanel id="agencyOutputPanel"
layout="inline"
+ styleClass="linePanel">
+ <a4j:commandLink id="agencyCommandLink"
+ value="#{dataManager.selectedAgency.desc}"
+ action="#{dataManager.commandAction}"
+ actionListener="#{dataManager.commandActionListener}"
+ reRender="selectPanel" />
+ </a4j:outputPanel></div>
+ </div>
+ <a4j:outputPanel id="selectPanel" layout="block"
+ style="float:left;margin-top:5px;margin-left:5px;width:200px;">
+ <a4j:repeat id="selectDataList"
+ binding="#{dataManager.selectDataList}"
+ value="#{dataManager.selectData}" var="item"
+ ajaxKeys="#{dataManager.keys}">
+ <a4j:commandLink id="selectCommandLink" value="#{item.desc}"
+ action="#{dataManager.selectAction}"
+ actionListener="#{dataManager.selectActionListener}"
+ reRender="companyOutputPanel,agencyOutputPanel"
+ style="display:block" />
+ </a4j:repeat>
+ </a4j:outputPanel>
+ </a4j:form>
+ </body>
+</f:view>
+</html>
Copied: tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/push.xhtml (from rev 164,
trunk/samples/useCases/src/main/webapp/pages/push.xhtml)
===================================================================
--- tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/push.xhtml
(rev 0)
+++ tags/1_1_1_rc1/samples/useCases/src/main/webapp/pages/push.xhtml 2007-05-04 01:10:03
UTC (rev 168)
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+
xmlns:c="http://java.sun.com/jsp/jstl/core"
+ >
+ <body>
+ <f:view>
+ <a4j:push reRender="msg"
eventProducer="#{messageBean.addListener}" interval="3000"/>
+
+ <h:dataTable id="msg" value="#{messageBean.messages}"
var="msg">
+ <f:facet name="header"><h2>Messags :
</h2></f:facet>
+ <h:column>
+ Message :
+ </h:column>
+ <h:column>
+ <h:outputText value="#{msg}"></h:outputText>
+ </h:column>
+ </h:dataTable>
+ <h:form>
+ <a4j:status startText="Request started"
stopText="stop."></a4j:status>
+ </h:form>
+ <a4j:log hotkey="M"></a4j:log>
+ </f:view>
+ </body>
+</html>
\ No newline at end of file