JBoss.orgCommunity Documentation
The <a4j:form> component is very similar to JSF <h:form> the only difference is in generation of links inside and possibility of default Ajax submission.
Table 6.5. a4j : form attributes
Table 6.6. Component identification parameters
Name | Value |
---|---|
component-type | org.ajax4jsf.Form |
component-family | javax.faces.Form |
component-class | org.ajax4jsf.component.html.AjaxForm |
renderer-type | org.ajax4jsf.FormRenderer |
Component definition on a page is similar to definition of the original component from JSF HTML library.
Example:
<a4j:form>
<h:panelGrid>
<h:commandButton value="Button" action="#{userBean.nameItMark}" />
</h:panelGrid>
</a4j:form>
Example:
import org.ajax4jsf.component.html.AjaxForm;
...
AjaxForm myForm = new AjaxForm();
...
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.
Beginning with release 1.0.5 additional attributes that make this form variant universal have appeared.
If
"ajaxSubmit"
attribute is true, it becomes possible to set Ajax
submission way for any components inside with the help of the javascript
A4J.AJAX.Submit(...)
call. In this case, the
"reRender"
attribute contains a list of Ids of components defined for
re-rendering. If you have
<h:commandButton>
or
<h:commandLink>
inside the form, they work as
<a4j:commandButton>
.
Example:
<a4j:form id="helloForm" ajaxSubmit="true" reRender="table">
...
<t:dataTable id="table"... >
...
</t:dataTable>
...
<t:datascroller for="table"... >
...
</t:datascroller>
...
</a4j:form>
This example shows that in order to make <t:datascroller> submissions to be Ajax ones it's required only to place this <t:datascroller> into <a4j:form> . In the other case it is necessary to redefine renders for its child links elements that are defined as <h:commandLink> and can't be made Ajax ones with using e.g. <a4j:support> .
With the help of
"limitToList"
attribute you can limit areas, which are updated after the responses.
If
"limitToList"
is true, only the reRender attribute is taken in account.
Therefore, if you use blocks of text wrapped with
<a4j:outputPanel>
and ajaxRendered= "true"
, blocks of text are ignored.
Information about the "process" attribute usage you can find in the "Decide what to process" guide section.
Vizit AjaxForm at RichFaces Livedemo for examples of component usage and their sources. a