[
https://issues.apache.org/struts/browse/WW-2526?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Don Brown resolved WW-2526.
---------------------------
Resolution: Fixed
Fix Version/s: 2.1.3
Assignee: Don Brown
Fixed, and while I was at it, I disabled the interceptor when it detected
multiple checkboxes with the same name, as it couldn't possibly figure out
which ones were checked and which ones weren't.
> CheckboxInterceptor incorrectly sets attributes as simple String primitives
> instead of String array
> ---------------------------------------------------------------------------------------------------
>
> Key: WW-2526
> URL: https://issues.apache.org/struts/browse/WW-2526
> Project: Struts 2
> Issue Type: Bug
> Components: Core Interceptors
> Affects Versions: 2.0.9
> Environment: Firefox 2.0.0.12, Internet Explorer 7
> Reporter: Tim Stavenger
> Assignee: Don Brown
> Fix For: 2.1.3
>
>
> When the CheckboxInterceptor sets request parameters for unchecked check
> boxes, it adds a new parameter with the key has the name of the field and a
> value of a single String, "false". See:
> private String uncheckedValue = Boolean.FALSE.toString();
> ...
> newParams.put(name, uncheckedValue);
> The problem here is that names are not unique on elements in the HTML DOM, so
> there really could be multiple values for each name. Firefox and Internet
> Explorer handle this by passing String arrays as request parameters. However,
> request parameters created by the CheckboxInterceptor will not be an array.
> This becomes an issue when you write an OGNL PropertyAccessor for fields that
> include check boxes. TypeConverters have a String array as an explicit method
> parameter, but PropertyAccessors only have an Object (which the code has to
> cast). I haven't tested this with a TypeConverter, but I know that with the
> PropertyAccessor the class will now always get String arrays as the value
> except when the CheckboxInterceptor has set the value. I would wonder if
> TypeConverters would get a ClassCastException since not all parameters would
> be String arrays when working with parameters set by the CheckboxInterceptor?
> I think it would be better for the CheckboxInterceptor to simply set a String
> array in the first place, matching the rest of the request parameters. So I
> propose in line 53 (of the 2.0.9 code base), the line be changed from;
> private String uncheckedValue = Boolean.FALSE.toString();
> To:
> private String[] uncheckedValue = {Boolean.FALSE.toString()};
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.