I was wondering what the proper solution should be and didn't find any :\

You can always add id attribute your self - this should work

<s:hidden id="'hidden-'+%{#user.id}" name="userIds" value="%{#user.id}" />
<s:select id="'groups'++%{#user.id}" list="groupList" name="groupIds"
value="%{groupValues[#user.id]}" />

but it means we shouldn't autogenerate IDs which can break few things :/

2014-09-21 14:15 GMT+02:00 Heikki Hyyrö <heikki.hy...@uta.fi>:
> Lukasz Lenart <lukaszlen...@apache.org> kirjoitti 21.9.2014 kello 11.48:
>> Can you prepare some exact example app?
>
>
> Would the example snippet at the bottom be enough? It shows a slightly 
> cleaned version of one form we use. The form basically consists of a table 
> that lists the users of the system. Each user can be assigned to a user 
> group. This form sends two arrays to the action updateGroups: one is 
> ”userIds”, which contains the user ids, and the other one is ”groupIds”, 
> which contains the group ids (which may be changed via the select-list in the 
> last column).
>
> Struts generates identical id for each input field that gives values to these 
> two lists. For example if there are 500 users, the html-code output by Struts 
> will contain 500 snippets that look like:
>
> <input type="hidden" name="userIds" value="4267" 
> id="updateUserGroups_userIds"/><select name="groupIds" 
> id="updateUserGroups_groupIds">
>
> Each of these snippets will differ only in what is the value of the first 
> hidden field. WWW validator will then output hundreds of errors of form 
> "Duplicate ID updateUserGroups_groupIds” and "Duplicate ID 
> updateUserGroups_userIds”.
>
> In this particular case the problem might(?) go away if the form used 
> explicit index notation with the array names ”userIds" and "groupIds", but as 
> far as I know (e.g. based on the book Struts 2 in Action), the practice of 
> populating arrays without explicit indexing is quite normal.
>
> -Heikki
>
>
> <s:form action="updateGroups">
>     <table class="tablesorter" id=”userTable">
>       <thead>
>         <tr>
>           <th>Name</th>
>           <th>Login</th>
>           <th>Email</th>
>           <th>Group</th>
>         </tr>
>       </thead>
>       <tbody>
>         <s:iterator var=”user" value=”users">
>           <tr>
>             <td>
>               <s:url action="viewUser" var="viewUserUrl">
>                 <s:param name="userId" value="%{#user.id}" />
>               </s:url>
>               <s:a href="%{viewUserUrl}">
>                 ${user.lastName}, ${user.firstName}
>               </s:a>
>             </td>
>             <td>${user.login}</td>
>             <td><a href="mailto:${user.email}";>${user.email}</a></td>
>             <td>
>               <s:hidden name="userIds" value="%{#user.id}" />
>               <s:select list="groupList" name="groupIds" 
> value="%{groupValues[#user.id]}" />
>             </td>
>           </tr>
>         </s:iterator>
>       </tbody>
>     </table>
>     <p>
>       <input type="submit" value=”Save changes" />
>     </p>
>   </s:form>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to