您的位置:首页 > Web前端 > JavaScript

< a4j:jsFunction >

2016-02-22 13:58 561 查看
转载地址:http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html_single/


6.1.8.  < a4j:jsFunction > available since 3.0.0

expand all
6.1.8.1. Description 6.1.8.2.
Details of Usage 6.1.8.3. Reference Data 6.1.8.4.
Relevant Resources Links


6.1.8.1. Description

The  component allows to perform Ajax requests directly from JavaScript code, invoke server-side data and return it in a JSON format to use in a client JavaScript
calls.


6.1.8.2. Details of Usage

As the component uses Ajax request to get data from server it has all common Ajax Action attributes. Hence, "action" and "actionListener" can
be invoked, and reRendering some parts of the page fired after calling function.

When using the  it's possible to initiate the Ajax request from the JavaScript and perform partial update of a page and/or invoke the JavaScript function with
data returned by Ajax response.
...

<body onload="callScript()">

     

             ...

            <a4j:jsFunction name="callScript" data="#{bean.someProperty1}" reRender="someComponent" oncomplete="myScript(data.subProperty1, data.subProperty2)">

                  <a4j:actionparam name="param_name" assignTo="#{bean.someProperty2}"/>

            </a4j:jsFunction>

            ...

     

      ...

</body>

...

 

The  allows to use  or pure  for
passing any number of parameters of the JavaScript function into Ajax request. is similar to  , but it could be activated from
the JavaScript code. It allows to invoke some server-side functionality and use the returned data in the JavaScript function invoked from "oncomplete" attribute. Hence it's possible to use  instead
of . You can put it anywhere, just don't forget to use  and  around
it.

Information about the "process" attribute usage you can find "Decide
what to process" guide section.


6.1.8.3. Reference Data

Table of attributes.

Table 6.8. Component Identification Parameters

NameValue
component-typeorg.ajax4jsf.Function
component-familyorg.ajax4jsf.components.ajaxFunction
component-classorg.ajax4jsf.component.html.HtmlajaxFunction
renderer-typeorg.ajax4jsf.components.ajaxFunctionRenderer


6.1.8.4. Relevant Resources Links

Visit the jsFunction page at RichFaces LiveDemo for component
usage and sources for the given examples.

Useful articles:

"<
4000
a href="http://www.jboss.org/community/docs/DOC-11856" style="text-decoration:none;color:rgb(51,153,255);">JsFunctionJson" article in the RichFaces Cookbook describes how to use "a4j:jsFunction" to call the jsonTest
backing bean that generates some random data in a JSON String;

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: