### Create new RichFaces Documentation Jira issue

Summary
255 characters left
Description
Environment
This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.org Community Documentation

- Prev
- Next

### 6.1.3. < a4j:form > available since 3.0.0

expand all

#### 6.1.3.1. Description

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.4. a4j : form attributes

Attribute Name | Description
--- | ---
accept | HTML: This attribute specifies a comma-separated list of content types that a server processing this form will handle correctly. User agents may use this information to filter out non-conforming files when prompting you to select files to be sent to the server (cf. the INPUT element when type="file")
acceptCharset | This attribute specifies the list of character encodings for input data that is accepted by the server processing this form. The value is a space- and/or comma-delimited list of charset values. The client must interpret this list as an exclusive-or list, i.e., the server is able to accept any single character encoding per entity received. The default value for this attribute is the reserved string "UNKNOWN". User agents may interpret this value as the character encoding that was used to transmit the document containing this FORM element
ajaxSingle | Limits JSF tree processing (decoding, conversion, validation and model updating) only to a component that sends the request. Boolean
ajaxSubmit | If "true", it becomes possible to set AJAX submission way for any components inside .
binding | JSF: The attribute takes a value-binding expression for a component property of a backing bean
bypassUpdates | If "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
data | Serialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
enctype | This attribute specifies the content type used to submit the form to the server (when the value of method is "post"). The default value for this attribute is "application/x-www-form-urlencoded". The value "multipart/form-data" should be used in combination with the INPUT element, type="file"
eventsQueue | Name of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focus | ID of an element to set focus after request is completed on client side
id | JSF: Every component may have a unique id that is automatically created if omitted
ignoreDupResponses | Attribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
iterationState | iterationState
limitToList | If "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdate | The client-side script method to be called before DOM is updated
oncomplete | The client-side script method to be called after the request is completed
onreset | DHTML: The client-side script method to be called when a form is reset. It is only applied to the FORM element
onsubmit | DHTML: The client-side script method to be called when a form is submitted. It is only applied to the FORM element
prependId | The flag indicating whether or not this form should prepend its id to its descendent id during the clientId generation process. If this flag is not set, the default value is "true".
process | Id['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rendered | JSF: If "false", this component is not rendered
requestDelay | Attribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRender | Id['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
similarityGroupingId | If there are any component requests with identical IDs then these requests will be grouped.
status | ID (in format of call UIComponent.findComponent()) of Request status component
style | HTML: CSS style rules to be applied to the component
styleClass | JSF: Assigns one or more CSS class names to the component. Corresponds to the HTML "class" attribute.
target | HTML: This attribute specifies the name of a frame where a document is to be opened. By assigning a name to a frame via the name attribute, authors can refer to it as the "target" of links defined by other elements
timeout | Timeout ( in ms ) for request.

Table 6.5. 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

#### 6.1.3.2. Creating the Component with a Page Tag

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>

#### 6.1.3.3. Creating the Component Dynamically Using Java

Example:

    import org.ajax4jsf.component.html.AjaxForm;

    ...

    AjaxForm myForm = new AjaxForm();

    ...

#### 6.1.3.4. Details of usahe

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.

#### 6.1.3.5. Relevant resources links

Vizit AjaxForm at RichFaces Livedemo for examples of component usage and their sources. a

- Prev6.1.2. < a4j:actionparam > ...
- Top of page
- Front page
- Next6.1.4. < a4j:region > ...