a4j:actionparam is a component that combines together the functionality of f:param and ActionListener.
Additionally to the f:param, this component allows to assign the value to the property of the manager bean
directly using the assignTo attribute.

ActionParameter Demo

Selected Name:

HideView Source

<ui:compositionxmlns="http://www.w3.org/1999/xhtml"xmlns:ui="http://java.sun.com/jsf/facelets"xmlns:h="http://java.sun.com/jsf/html"xmlns:a4j="http://richfaces.org/a4j"xmlns:rich="http://richfaces.org/rich"><h:form><rich:panelbodyClass="rich-laguna-panel-no-header"><a4j:commandButtonvalue="Set Name to Alex"reRender="rep"><a4j:actionparamname="username"value="Alex"assignTo="#{userBean.name}"/></a4j:commandButton><rich:spacerwidth="20"/><a4j:commandButtonvalue="Set Name to John"reRender="rep"><a4j:actionparamname="username"value="John"assignTo="#{userBean.name}"/></a4j:commandButton></rich:panel><rich:spacerheight="1"/><rich:panelbodyClass="rich-laguna-panel-no-header"><h:outputTextid="rep"value="Selected Name:#{userBean.name}"/></rich:panel></h:form></ui:composition>

<<Hide Source

You can use a4j:param not only with ajax components, but with non-ajax command component also.
In the following example, the used skin of the demo is changed when the whole page is refreshed
with the regular non-ajax h:commandLink. Using this feature you can update model values without
invoking even a single line of java code on the server side.

Attributes 'name' and 'value' are mandatory. You can specify the converter with 'converter'
attribute if you need to convert the value before the model is updates. Note that
the property is assigned with a parameter value on the UPDATE_MODEL phase. Thus, if
the validation of the form is failed, this phase will be skipped and the property
is not updated.

It is possible to use javascript variable of custom function for the 'value' attribute. In this
case the 'noEscape' attribute should be set to true. When noEscape="true", the 'value' can contain
any javascript expression or javascript function invocation and the result of them will be send
to the server as a value of a4j:actionparam. The following example demonstrates how to assign
the backing bean with browser screen size values.