Thursday, August 19, 2010

Spring:form bug creates invalid “id”

Spring 3.0.1 inadvertently broke the indexed properties which are set by the form tag when “path” is used.

eg.

<c:forEach items="${continent.countries}" var="entry">
<div>
<form:input path="countries[${entry.key}]" />
</div>
</c:forEach>

 

Spring 3.0.1 generates

<div>
<input type=”text” name="countries0" id=”countries0” value=”Belgium”></input>
</div>

Instead it should generate:-

<div>
<input type=”text” name="countries0" id=”countries[0]” value=”Belgium”></input>
</div>

Notice the brackets [ ] in the id. This results in failure in binding the values to the form. A JIRA issue has been raised for this: https://jira.springframework.org/browse/SPR-6871?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel#issue-tabs. The bug was fixed and released in Spring 3.0.4

No comments:

Post a Comment

Thank you for your feedback