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
    Affects Versions: 2.0.9
         Environment: Firefox 2.0.0.12, Internet Explorer 7
            Reporter: Tim Stavenger


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.

Reply via email to