Announcement Announcement Module
Collapse
No announcement yet.
Rejected value for Array binding other than String array returns null. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rejected value for Array binding other than String array returns null.

    When trying to bind to array field other than of String instance, e.g. Integer[], if there's a bind exception, the rejected value returned will be null (because there's no path matching of the field error), e.g.

    class {
    private Integer[] quantities;
    // getter & setter method
    }

    Quantity 1: .. <input name="quantities" .../>
    Quantity 2: ... <input name="quantities" .../>

    Scanned through the codes, I find that something is not so right with regards to handling of array conversion other than string.

    BeanWrapperImpl (line 897):

    for (Iterator it = coll.iterator(); it.hasNext(); i++) {
    Object value = doTypeConversionIfNecessary( propertyName, propertyName + PROPERTY_KEY_PREFIX + i + PROPERTY_KEY_SUFFIX, null, it.next(), componentType);
    Array.set(result, i, value);
    }

    If Quantity 2 value is not a number, this will trigger TypeMismatch for field "quantities[2]" with rejected value "xxxx".

    I think type mismatch handling should treat the input array as a whole, and return mismatch with field value "quantities" and rejected array of submitted quantity1 and quantity 2 values.

    Please correct me if I'm wrong, unless that I should be using other way to handle such scenario.
Working...
X