Set JSF-component attributes by clicking a button
Why
You want to skip validation of an input text component. You want to change, e.g. the disable or render attribute of a component from true to false by clicking a button to refresh the (parent) component.
How
Add request parameter to your buttons requiring validation:
<p:button value="Save" actionListener="#{viewBean.saveAction}"> <f:param name="requireValidation" value="1"></f:param> </p:button>
Set the required attribute of your input component:
<h:inputText value="#{viewBean.inputTextField}" required="#{param['requireValidation']=='1'}" /> </verbatim> </pre>
You can query the parameter anywhere in your backing bean:
public boolean isRequiredValidation() { return "1".equals(FacesContext.getCurrentInstance() .getExternalContext().getRequestParameterMap() .get("requiredValidation")); }
See also the <f:attribute />
tag for passing values to event-handlers.
Source Prasun's Techblog, 2009
Date: 2011-02-11 Fr
HTML generated by org-mode 7.4 in emacs 22