PhotoAlbum Application Download Support Developer Guide
Skins:
Resources/Beans Handling
Ajax Miscellaneous
Usage
Tag Information

a4j:form functionality is similar to the standard h:form component except two additional features:

  • Along with a4j:htmlCommandLink, it fixes the problem of h:commandLink component that cannot be re-rendered without re-rendering the whole form it belongs to.
  • It might convert all non-ajax action components (including the third party components) to the ajaxian ones if ajaxSubmit attribute is set to true

h:commandLink renderer generates the javascript code that is used to submit the form when the link is clicked. However, if the h:commandLink is rendered outside of the form, for example, when you point to it with reRender, the wrong code is generated that causes the broken functionality when user clicks this link later. The example of problematic code is below. To fix the code, you need to replace h:form with a4j:form and h:commandLink with a4j:htmlCommandLink.

Code Example
  ....
  <-- This code does not work correctly after the link is re-rendered -->
  <h:form>
        ....
        <a4j:commandButton value="Update Non-Ajax Link" reRender="panel" />
        ....
        <h:panelGrid id="panel">
            ....
            <h:commandLink value="Non-Ajax Submit" action="foo" >
                ...
            </h:commandLink>  
            ....
        </h:panelGrid>
        ....
  </h:form>

When ajaxSubmit="true", all standard action components on this form become ajaxable. This approach is similar to the one AjaxAnywhere framework uses. If a form works in an ajax mode, the standard ajax attribute such as reRender, eventQueue, requestDelay can be used. The following example shows the difference between partial and full-page refreshing. In both cases, the regular h:commandButton is used for the form submission.

AjaxForm Demo
Form with ajaxSubmit equals true
Name:
Form with ajaxSubmit equals false
Name:


View Source

Note:You should not use a4j:form ajaxSubmit="true" if it contains other ajax command components. Also, due to the security reason, uploadFile form element cannot be convertible to the be ajaxable.

For additional information about attributes of this component read 'Ajax Attribute' section .

RichFaces Wiki RichFaces Project Site