Grouping components under <f:ajax> tag

Sometimes, it may be useful to group multiple components under the same <f:ajax> tag. For example, the following code snippet groups two <h:inputText> components under the same <f:ajax> tag (you can nest other components as well):

<f:ajax event="click" execute="submitFormId" render="submitFormId"> <h:form id="submitFormId"> Name: <h:inputText id="nameId" value="#{ajaxBean.name}" validator="nameValidator"/> <h:message id="msgNameId" showDetail="true" showSummary="true" for="nameId" style="color: red;"/> Surname: <h:inputText id="surnameId" value="#{ajaxBean.surname}" validator="nameValidator"/> <h:message id="msgSurnameId" showDetail="true" showSummary="true" for="surnameId" style="color: red;"/> </h:form> ...

Get Mastering JavaServer Faces 2.2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.