JBoss.orgCommunity Documentation
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.
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 during the "Process Request" phase.
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.
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> .
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 |
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.