6.1.2. < a4j:actionparam > 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.2. < a4j:actionparam > available since 3.0.0

expand all

#### 6.1.2.1. Description

The <a4j:actionparam> component combines the functionality of <f:param> and <f:actionListener> and allows to assign the value to the property of the managed bean directly using the "assignTo" attribute.

#### 6.1.2.2. Details of Usage

The <a4j:actionparam> component has 3 main attributes:

- "name" defines a name of this parameter

- "value" defines initial value of this parameter or a value binding

- "assignTo" defines updatable bean property. This property will be updated if the parent command component performs an actionEvent. The update occurs in the same phase as the actionEvent is processed (`INVOKE_APPLICATION`, `PROCESS_VALIDATIONS`, or `APPLY_REQUEST_VALUES`, depending on the values of the "immediate" and "bypassUpdates" attributes).

Example:

    ...

    <h:form id="form">

        <a4j:commandButton value="Set Name to Alex" reRender="rep">

            <a4j:actionparam name="username" value="Alex" assignTo="#{actionparamBean.name}"/>

        </a4j:commandButton>

        <br/>

        <h:outputText id="rep" value="Name: #{actionparamBean.name}"/>

    </h:form>

    ...

There is a managed bean:

    ...

    public class ActionparamBean {

        private String name = "John";

        public String getName() {

            return name;

        }

        public void setName(String name) {

            this.name = name;

        }

    }

    ...

You can use <a4j:actionparam> not only with Ajax components, but with non-ajax command component also. This feature allows to update model values without invoking even a single line of Java code on the server side. The usage of this feature you can find at ActionParameter Usage page of RichFaces LiveDemo.

If you need to convert the value before the "Update Model" phase you can specify the converter in the "converter" attribute.

## Note:

The property is assigned with a parameter value on the "Update Model" phase. Therefore if the validation of the form is failed, this phase will be skipped and the property won't be updated.

It is possible to use JavaScript expression or function in the "value" attribute. In this case the "noEscape" attribute should be set to "true". The result of this JavaScript invocation is sent to the server as a value of <a4j:actionparam> .

#### 6.1.2.3. Reference Data

Table of <a4j:actionparam> attributes.

Table 6.2. Component Identification Parameters

Name | Value
--- | ---
component-type | org.ajax4jsf.ActionParameter
component-class | org.ajax4jsf.component.html.HtmlActionParameter

#### 6.1.2.4. Relevant Resources Links

Visit the ActionParameter page at RichFaces LiveDemo for examples of component usage and their sources.

More information can be found on the Ajax4jsf Users Forum.

More information about <f:param> and <f:actionListener> can be found in Sun JSF TLD documentation.

- Prev6.1.1. < a4j:ajaxListener ...
- Top of page
- Front page
- Next6.1.3. < a4j:form > ...