The problem is how to bind back the modified name ? We tried using PropertyEditor but this is handy to transform some data to String and back. I searched the web but at last, I understood how to do that very easily.
<ul> <c:forEach items="${form.actors}" var="actor" varStatus="status"> <li> <form:hidden path="actors[${status.index}].id" /> <form:input path="actors[${status.index}].name" /> </li> </c:forEach> </ul>
Et voilĂ !
The id is bound back to the Actor as the modified name.
Note : the actors collection must be a List or an Array.
Those damn simple 8 lines are exactly what I've been looking for the whole afternoon !
ReplyDeleteYou saved my day :)
Thanks. It is exactly why I wanted to post this kind of thing.
DeleteFYI, you should consider using an secure token in your form to protect it as someone can change the id of the entity. This in known as CSRF.