I'm working with the current 1.0 release of Struts, but my problem
relates to BeanUtils PropertyUtils class (as used in the next release
of Struts) as well as the current implementation.

I'm trying to use an ArrayList for my IndexedProperty, but
PropertyUtils.getIndexedProperty(bean, name, index) doesn't support
anything other than regular Arrays.  I'd like to propose the following
(or something like it) change to allow support of Lists:

// Call the property getter and return the value
Object value = readMethod.invoke(bean, new Object[0]);
if (value.getClass().isArray()) 
    return (Array.get(value, index));
else if (value instanceof java.util.List)
    return ((List)value).get(index);
else
    throw new IllegalArgumentException("Property '" + name +
                                       "' is not indexed");

A similar change would need to be made to setIndexedProperty(bean,
name, index, value):

// Call the property getter to get the array
Object array = readMethod.invoke(bean, new Object[0]);
if (array.getClass().isArray())
    Array.set(array, index, value);
else if (array instanceof java.util.List)
    ((List)array).set(index, value);
else
    throw new IllegalArgumentException("Property '" + name +
                                       "' is not indexed");


=====
Lance Lavandowska
Http://www.brainopolis.com/

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Reply via email to