At the moment <spring:bind> only allows absolute paths to objects registered in the model. <spring:nestedPath> allows only an abbreviation of this path. I wonder why it is not possible to set something like a relative path. This would enable "real" iterating over collections as you would no longer need to rely on indices. So it would also enable iterating over non-indexed collections like maps.
This would be ways cleaner than the code I found in SPR-52 or in the thread "Error while accessing collections". Of course it introduces issues like identifying the elements and refinding the same one. But I wonder if those would not be solvable.Code:<c:forEach items="${collection}" var="collEntry"> <!-- @newPath refers to @var in c:forEach --> <!-- @var contains the name to refer to this context, might be superfluous --> <spring:newPath var="localName" newPath="collEntry"> <tr> <td> <spring:bind path="localName.key">${status.value}</spring:bind> </td> <td> <spring:bind path="localName.value">${status.value}</spring:bind> </td> </tr> </spring:newPath> </c:forEach>
It would enable the usage of <c:forEach> as it was supposed to be used and it would match similar concepts in XSLT (XML/XPath).
Jörg


Reply With Quote