You need to use commandButton
and actionParam
to pass the dynamic parameter back to the server.
In addition, you need an attribute of your bean that will receive the parameter value.
Example:
<a4j:commandButton action="#{myBean.action}" value="Submit!"> <a4j:actionParam name="arg" noEscape="true" value="getTheValue()" assignTo="#{myBean.myBeanArg}" /> </a4j:commandButton>
Here myBean.myBeanArg
will get the value returned by the javascript getTheValue()
function.
Note the noEscape="true"
attribute. This is necessary because otherwise the data inside the value
will be enclosed in single quotes and escaped, which will lead to javascript execution. As stated in the documentation :
You can use an expression or JavaScript function in the value of the "value" attribute. In this case, the noEscape attribute should be set to true. The result of this JavaScript call is sent to the server as the value of <a4j:actionparam>
.
source share