I have a JSF2 application that uses <ui:repeat />
to render a number of text-boxes, each linked to an item in a collection. I need to show the error messages after the inputs in a single <h:messages />
tag.
At the same time, I have some other required fields outside the <ui:repeat />
tag, which
should have its error message next to their input, therefore they will have a corresponding <h:message />
tag. The problem here is that each time I have triggered the outside field's validation, its message appears also in the <h:messages />
tag of the <ui:repeat />
.
Here is the code:
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><h:outputLabel value="Items"/></td>
<td>
<ui:repeat var="i" value="#{itemsBean.itemsCount}" id="items">
<h:inputText id="itemTitle" value="#{itemsBean.items[i]}" required="true" />
<h:panelGroup layout="block" styleClass="clear" rendered="#{((i+1) % 10 == 0)}" />
</ui:repeat>
<h:messages id="itemsMessages" showDetail="false" showSummary="true" styleClass="error_list" />
</td>
<td><h:outputLabel value="Required Field" /></td>
<td>
<h:inputText id="requiredField" value="#{itemsBean.requiredField}" />
<h:message for="requiredField" showDetail="false" showSummary="true" styleClass="error_list" />
</td>
</tr>
</table>
I know that this is the way JSF validation works, but I need to prevent the outside input's message from appearing in the repeated items validation summary. Thanks in advance.