Spring – c:foreach and hibernate’s maps / lists

iterating over a list / set can be done via;

<c:forEach items=”${job.jobPhotos}” var=”photo” varStatus=”idx”>
<form:hidden path=”jobPhotos[${idx.index}].id” />

Iterating over a map can be done via;

<c:forEach items=”${job.jobPhotos}” var=”current”>
<form:hidden path=”jobPhotos[${current.key}].id” />

${current.key} and ${current.value.id} are equilivant (both equate to the ID of the row being iterated over)

http://www.steve-farmer.com/examples/jstl/ui/c-foreach-map.jsp
http://blog.vergiss-blackjack.de/2010/04/iterating-over-nested-objects-in-a-spring-form/

Hibernate Annotations – Bidirectional One-To-Many

Leave a Reply