Announcement Announcement Module
Collapse
No announcement yet.
Hibernate Command Object with Set Field Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate Command Object with Set Field

    I am using a Hibernate code generated bean as a command object in my Spring MVC web application. The command has a field which is of type java.util.Set which needs to be represented in the form. This seems difficult, however, because a Set cannot be represented as an indexed property since it is not indexable (doesn't implement java.util.List). I do not want to convert this field to a List because in Hibernate this would require an additional index column on the child table even though we don't care about ordering.

    Is there a way to represent a java.util.Set field in a form?

    Thanks

    karl

  • #2
    If you're using JSTL, you can use
    Code:
    <c&#58;forEach var='item' items='$&#123;mySet&#125;' varStatus='status'>
    <option id="<c&#58;out value='$&#123;status.index&#125;'/>" value="<c&#58;out value='$&#123;item.id&#125;'/>"><c&#58;out value='$&#123;item.value&#125;'/></option>
    </c&#58;forEach>
    Of course the same effect can be reached by simply using Java scriptlets like with mySet.iterator().

    Comment

    Working...
    X