Issue 1:
Tom Chambers opened SPR-7007 and commented

When binding to a list or map in a form tag, in my case:

<form:checkbox path="command[${mapkey}][${i.index}].aList" value="${aValue}" />

The checkbox is correctly bound and rendered (using a custom property editors etc), however on submission the request parameters are not correctly bound to the form object. After investigation it appears that the HTML "name" attribute of the input field is incorrect, before 3.0.1 (RELEASE-A) it would render:

<input id="commandkeyvalue0.aList.subscriptionMethods1" name="command[keyvalue][0].aList.subscriptionMethods1" type="checkbox" value="aValue" checked="checked"/>
<input type="hidden" name="_command[keyvalue][0].aList.subscriptionMethods1" value="on"/>

It now renders:

// Note the missing square brackets in the name
<input id="commandkeyvalue0.aList.subscriptionMethods1" name="commandkeyvalue0.aList.subscriptionMethods1" type="checkbox" value="aValue" checked="checked"/>
<input type="hidden" name="_commandkeyvalue0.aList.subscriptionMethods1" value="on"/>

I am aware that in 2.5 the "id" attribute of input fields were changed to remove the square brackets [ and ]. However it seems that the "name" also has these removed causing the request parameters to not be bound on submission of the form. Manually editing the HTML to include the [ and ] characters in the "name" attribute fixes the issue.

Although I have found this in using the portlet API and the form:checkboxes/ tag, I suspect that it is common in the servlet code (and other form tags) too - it seems to be in AbstractDataBoundFormElementTag:

In 3.0.0 (working):

protected String autogenerateId() throws JspException {
return StringUtils.deleteAny(getName(), "[]");
}

protected String getName() throws JspException {
return getPropertyPath();
}

In 3.0.1 RELEASE A:

protected String autogenerateId() throws JspException {
return getName();
}

protected String getName() throws JspException {
return StringUtils.deleteAny(getPropertyPath(), "[]");
}

Please feel free to shoot me down - I have spent a while on this and I cant see how the above is supposed to work.

Affects: 3.0.1

Issue Links:

#11654 Spring web's tag library removes "[" and "]" in the path attribute for input (and possibly others). ("duplicates")

Issue 2:
Ken Egervari opened SPR-6989 and commented

I have some code that purposefully puts "[" and "]" in the path, which eventually gets rendered to the id and name attributes on the input tag.

Code:

<@springForm.input type=type attributes=attributes path=path htmlEscape="true" /><br/>

At a high level, it gets used like this:

Code:

<@form.text path="studentAnswer.answers[${chunk.text}]" />

Unfortunately, spring's tag library is removing the "[" and "]", so what is left over is a giant string value. I must use this pattern since this page has multiple input fields that are totally random based on the list of text chunks.

Each form value is supposed to map to this:

private Map<String,String> answers = new HashMap<String, String>();

Of course, when the server tries to get the values, there are NPE's everywhere due to Spring's stupidity.

How did this break? I was using plain html before, and I just recently switched over to the tag library because it was the only way to get multipart's working correctly. Otherwise, Spring didn't pass the MultipartFile object to the domain object. I tried everything, and this is what fixed it.

Now that I have converted about 50 forms to use the tag library, I have finally arrived to the 1 outlier form that does not covert over successfully. Sigh.

Please tell me how I can get this to work so I can get this production code launched.

Affects: 3.0.1

Reference URL: http://forum.springsource.org/showthread.php?t=86199

Issue Links:

#11672 AbstractDataBoundFormElementTag generates incorrect input name attribute when using indexed properties ("is duplicated by")