6.1.7. < a4j:commandLink > available since 3.0.0

### 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.7. < a4j:commandLink > available since 3.0.0

expand all

#### 6.1.7.1. Description

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.

#### 6.1.7.2. Details of Usage

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:

Figure 6.4. The RicjFaces greeter with <a4j:commandLink>

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.

## Note:

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.

#### 6.1.7.3. Reference Data

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

#### 6.1.7.4. Relevant Resources Links

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.

- Prev6.1.6. < a4j:commandButton > ...
- Top of page
- Front page
- Next6.1.8. < a4j:jsFunction > ...