JBoss.orgCommunity Documentation
The <a4j:commandLink> component is very similar to the <h:commandLink> component, the only difference is that an Ajax form submit is generated on a click and it allows dynamic rerendering after a response comes back. It's not necessary to plug any support into the component, as Ajax support is already built in.
The <a4j:commandLink> component is used in the same way as JSF <h:commandLink> . The difference is that in case of <a4j:commandLink> the components to be updated should be specified. In this chapter we will use the code from RichFaces Greeter and change there <a4j:commandButton> to <a4j:commandLink> :
...
<a4j:commandLink value="Get greeting" reRender="greeting" />
...
It's not necessary to add nested <a4j:support> as the <a4j:commandLink> has an Ajax support already built-in. As a result of our changes we will get a form with "Get greeting" link instead of the button:
The example above generates the following HTML code:
<a href="#" onclick="A4J.AJAX.Submit(?"request parameters"); return false;"><span>Get greeting</span></a>
If you click on the generated anchor the utility method A4J.AJAX.Submit()
will be fired.
Common JSF navigation could be performed after Ajax submit and partial rendering, but Navigation Case must be defined as <redirect/> in order to avoid problems with some browsers.
As any Core Ajax component that sends Ajax requests and processes server responses the <a4j:commandLink> has all attributes that provide the required behavior of requests (delay, limitation of submit area and rendering, etc.)
Information about the "process" attribute usage you can find "Decide what to process" guide section.
Table of <a4j:commandLink> attributes.
Table 6.7. Component Identification Parameters
Name | Value |
---|---|
component-type | org.ajax4jsf.CommandLink |
component-family | javax.faces.Command |
component-class | org.ajax4jsf.component.html.HtmlAjaxCommandLink |
renderer-type | org.ajax4jsf.components.AjaxCommandLinkRenderer |
Visit CommandLink demo page at RichFaces live demo for examples of component usage and their sources.
Useful articles:
How to use "window.confirm" JavaScript with <a4j:commandLink> "onclick" attribute in RichFaces cookbook at JBoss portal.