Author: SergeySmirnov
Date: 2007-07-26 15:40:32 -0400 (Thu, 26 Jul 2007)
New Revision: 1874
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxAttributes/usage.xhtml
Log:
ajax attributes complete
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxAttributes/usage.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxAttributes/usage.xhtml 2007-07-26
17:10:20 UTC (rev 1873)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/ajaxAttributes/usage.xhtml 2007-07-26
19:40:32 UTC (rev 1874)
@@ -206,12 +206,51 @@
</ol>
<h1 class="hsample">Javascript Interactions</h1>
<p>
-
- </p>
+ RichFaces allows to write Ajax-enabled JSF application without using
Javascript hard.
+ However, you can still invoke the javascript code if you need. There are several
ajax
+ attributes that helps to do it.
+ </p>
+ <p>
+ <b>onsubmit</b> attribute allows to invoke javascript code before the
Ajax request is
+ sent. If 'onsubmit' returns false, the Ajax request is canceled. The code of
'onsubmit'
+ is inserter before the RichFaces Ajax call. So, the 'onsubmit' should not has
a 'return'
+ statment is you want the Ajax request to be send. if you are going to invoke a
javscript
+ function that return true or false, use the conditional statment to return something
only
+ in you need to cancel the request. For example, onsubmit="if
(mynosendfunct()==false){return false}".
+ </p>
+ <p>
+ <b>onclick</b> attribute is similar to the 'onsubmit', but for
clickable components such
+ as a4j:commandLink and a4j:commandButton. If it returns false, the Ajax request is
canceled also.
+ </p>
+ <p>
+ <b>oncomplete</b> attribute allows to invoke the javascript code right
after the
+ Ajax response is returned back and the DOM tree of the browser is updated. Richfaces
+ register the code for further invocation to XMLHTTP request object before the Ajax
+ request is send. This means the code will not be changed during processing
+ the request on the server if you use JSF EL value binding. Also, you cannot use
+ 'this' inside the code, because it will not point the component where Ajax
request
+ was initiated.
+ </p>
+ <p>
+ <b>data</b> attribute allows to get the additional data from the server
during the
+ Ajax call. You can use JSF EL to point the property of the managed bean and its
value
+ will be serialized in JSON format and be available on the client side. You can refer
+ to it using the 'data' variable. For example:
+ </p>
+ <div class="esample">
+ <pre>
+ <a4j:commandButton value="Update"
data="<span>#</span>{userBean.name}"
oncomplete="showTheName(data.name)" />
+</h:inputText>
+ </pre>
+ </div>
+ <p>
+ Richfaces allows to serialize into JSON format not only primitive types, but complex
+ type including arrays and collections. The beans should be serializable to be
refered
+ with 'data'.
+ </p>
-
- </ui:define>
+ </ui:define>
<ui:define name="sources">
<span style="display:none"/>
</ui:define>
Show replies by date