[
http://issues.apache.org/jira/browse/MYFACES-583?page=comments#action_12329978
]
Peter Mahoney commented on MYFACES-583:
---------------------------------------
In HtmlCheckboxRender.renderGroupOrItemCheckbox() the following code does not
correctly set the checked property of checkboxes when the values are Integers:
boolean checked = (useSubmittedValues &&
lookupSet.contains(itemStrValue))
|| (!useSubmittedValues && lookupSet.contains(itemValue));
As the lookupSet always contains values which have already been converted into
Strings, the checked property can instead be set using:
boolean checked = lookupSet.contains(itemStrValue);
> "Error during model data update" using selectManyCheckbox
> ---------------------------------------------------------
>
> Key: MYFACES-583
> URL: http://issues.apache.org/jira/browse/MYFACES-583
> Project: MyFaces
> Type: Bug
> Components: Implementation
> Versions: Nightly Build
> Reporter: Peter Mahoney
>
> I have a selectManyCheckBox backed by an Integer array property. When the
> form is submitted, I get an exception thrown when updating the model:
> Caused by: javax.servlet.jsp.el.ELException: Attempt to coerce a value of
> type "[Ljava.lang.Object;" to type "[Ljava.lang.Integer;"
> It seems that the property is trying to be set with an Object array, rather
> than Integer array.
> I have tracked the problem down to _SharedRendererUtils:
> ...
> {
> //Object array
> int len = submittedValue.length;
> Object[] convertedValues = new Object[len];
> for (int i = 0; i < len; i++)
> {
> convertedValues[i]
> = converter.getAsObject(facesContext, component,
> submittedValue[i]);
> }
> return convertedValues;
> }
> ..
> Given that we know what type the array should be, a suggested patch for the
> code is:
> int len = submittedValue.length;
> ArrayList convertedValues = new ArrayList(len);
> for (int i = 0; i < len; i++)
> {
> convertedValues.add(i, converter.getAsObject(facesContext,
> component, submittedValue[i]));
> }
>
> return convertedValues.toArray((Object[])
> Array.newInstance(arrayComponentType, len));
> Peter
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira