I am displaying values from a set on a bean called AttributeDefinition which has a Set of ValidValues. I am able to display the set and change the values using the JSP below:
<c:forEach items="${attributeDefinition.validValues}" var="validValue" varStatus="validValueRow">
<form:hidden path="validValues[${validValueRow.index}].id"/>
<tr>
<td><form:input path="validValues[${validValueRow.index}].value"/></td>
</tr>
</c:开发者_开发问答forEach>
However, I want to be able to add an element to this set and have tried a few things and looked at the documentation, but I am unsure if this is possible with a Set, or if I have to do some conversion between a LazyList and my Set. Can someone let me know how to achieve this in the jsp and what code needs to be added to my controller? The Spring MVC documentation/book leave a lot to be desired.
For others coming across this issue, I've found that LazyList is the only way to dynamically add elements to a collection. If you are using a Set to hold your collection, you will need to map to and from the LazyList in your Spring Controller.
精彩评论