The a4j:jsFunction component creates a JavaScript function that allows you to send JSF Ajax requests from any JavaScript. You define the Ajax and JSF properties just like a4j:ajax, or a4j:commandButton, and a4j:jsFunction creates the JavaScript for you. The component sends a request using the standard JSF mechanisms. Note that this means a JSF form is required.
The following example shows how to use a4j:jsFunction to create a function named updateName. This is then called on mouseover of the different names. This triggers the full round trip Ajax request and renders the updated name.
<span onmouseover="updateAddress('WithoutBook')" onmouseout="updateAddress('')">WithoutBook</span>
<a4j:jsFunction name="updateAddress" render="showAddress">
<a4j:param name="address" assignTo="#{bean.address}" />
</a4j:jsFunction>
Enregistrer pour revision