AJAX and <f:param>
The <f:param>
tag can be used to pass request parameters to a managed bean. Since we have discussed this tag in detail in Chapter 2, Communication in JSF, we can continue here with an example of using it inside <f:ajax>
:
<h:form>
<h:inputText id="nameInputId" value="#{ajaxBean.name}"/>
<h:commandButton value="Send" action="#{ajaxBean.ajaxAction()}">
<f:ajax execute ="nameInputId" render="nameOutputId">
<f:param name="surnameInputId" value="Nadal"/>
</f:ajax>
</h:commandButton>
<h:outputText id="nameOutputId" value="#{ajaxBean.name}"/>
</h:form>
Remember that the parameter that was passed is available in the request parameter map:
FacesContext fc = FacesContext.getCurrentInstance(); Map<String, String> params = fc.getExternalContext().getRequestParameterMap(); logger.log(Level.INFO, "Surname: {0}", params.get("surnameInputId"));
Note
Keep in mind that <f:param...