Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-583

"Error during model data update" using selectManyCheckbox

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.1
    • 1.1.1
    • General
    • None

    Description

      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

      Attachments

        Activity

          People

            bruno_dev Bruno Aranda
            pmahoney Peter Mahoney
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: