a4j:commandLink

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

## Creating on a page

To create the simplest variant on a page use the following syntax:

Example:

    ...
       <a4j:commandLink reRender="someData" action="#{bean.action1}" value="Link"/>
    ...

## Creating the Component Dynamically Using Java

Example:

    import org.ajax4jsf.component.html.HtmlAjaxCommandLink;
    ...
    HtmlAjaxCommandLink myLink = new HtmlAjaxCommandLink();
    ...

## Key attributes and ways of usage

The <a4j:commandLink> component is used in the same way as the <h:commandLink> component, but with definition of the area that is updated after the response comes back from the server.

This definition of the component provides a link, and a click on the link causes an Ajax form submit on the server, `"action1"` method performance, and rendering of the component with `"someData"` id after the response comes back from the server.

Tip:

The example in the "Creation on a page" section generates the following HTML code:

    ...
    <a href="#" onclick="A4J.AJAX.Submit(?"request parameters"); return false;">
    	  <span>Link</span>
    </a>
    ...

If you click on the generated anchor the utility method `A4J.AJAX.Submit()` is fired. The method performs an Ajax request as the Ajax support is built-in. It's not necessary to add nested <a4j:support /> to the <a4j:commandLink /> component.

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 sending Ajax requests and processing server responses <a4j:commandLink> has all attributes described above (see <a4j:support> chapter) that provide the required behavior of requests sending (delay, limitation of submit area and rendering, etc.)

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

## Relevant resources links

Vizit 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.