Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my h:message for a specific id not displaying correctly in my dynamic form? More in description
    primarykey
    data
    text
    <p>I have a form which the user can dynamically add and remove a set of form fields (first name, last name, and email) from the form. That part is working fine, but of course I need some validation on those fields, and if I submit the form with just the first set of fields it works great, and I get validation on each field. Once I add the next set of fields and submit I get validation messages on the first set and only one field of the second. I am not really sure what is going on, but here is how <code>.xhtml</code> file looks:</p> <pre><code>&lt;h:form&gt; &lt;ui:repeat var="i" value="#{bean.list}"&gt; &lt;h:panelGrid columns="5" rowClasses="newRoow"&gt; &lt;h:inputText id="firstName" value="#{i.first_name}" required="true" requiredMessage="Please enter a First Name" /&gt; &lt;h:inputText id="lastName" value="#{i.first_name}" required="true" requiredMessage="Please enter a LastName" /&gt; &lt;h:inputText id="email" value="#{i.first_name}" required="true" requiredMessage="Please enter an Email Address"&gt; /&gt; &lt;h:commandButton value="+"&gt; &lt;f:ajax event="click" render="@form" listener="#{bean.addItemFromList}" /&gt; &lt;/h:commandButton&gt; &lt;h:commandButton value="-"&gt; &lt;f:ajax event="click" render="@form" listener="#{bean.removeItemFromList(i)}" /&gt; &lt;/h:commandButton&gt; &lt;h:message for="firstName" errorClass="warnings" showSummary="true" /&gt; &lt;h:message for="lastName" errorClass="warnings" showSummary="true" /&gt; &lt;h:message for="email" errorClass="warnings" showSummary="true" /&gt; &lt;/h:panelGrid&gt; &lt;/ui:repeat&gt; &lt;h:commandButton value="Submit" actionListener="#{bean.someFunction}" action="nextPage" /&gt; &lt;/h:form&gt; </code></pre> <p>Any ideas as to why this would be failing?</p> <p>With the first field set it is working great as you can see here: <a href="http://i.imgur.com/uMrrO.png" rel="nofollow">http://i.imgur.com/uMrrO.png</a> The validation is below each field.</p> <p>With the second and following field sets it looks like this: <a href="http://i.imgur.com/FeZ3T.png" rel="nofollow">http://i.imgur.com/FeZ3T.png</a> or a bit different because it seems to validate one more field every time I press the add button.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload