DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8364>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8364 java.util.List support for getIndexedProperty() Summary: java.util.List support for getIndexedProperty() Product: Commons Version: unspecified Platform: All OS/Version: Other Status: NEW Severity: Enhancement Priority: Other Component: Bean Utilities AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] While developping a application using struts we had to access elements of a List interface. this dosn't works with current beanutils. indexed access to 'Object[]' is implemented and with the same scheme it is also posible to access elements of 'java.util.List'. I have patched the class 'org.apache.commons.beanutils.PropertyUtils.java' to meet our requirements. I think this feature should added to beanutils. diff of org.apache.commons.beanutils.PropertyUtils.java follows: @@ -76,6 +76,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.commons.collections.FastHashMap; +import java.util.List; /** @@ -409,19 +410,25 @@ } } - // Otherwise, the underlying property must be an array + // Otherwise, the underlying property must be an array or a List Method readMethod = getReadMethod(descriptor); if (readMethod == null) throw new NoSuchMethodException("Property '" + name + "' has no getter method"); - // Call the property getter and return the value + // Call the property getter and return the value Object value = readMethod.invoke(bean, new Object[0]); - if (!value.getClass().isArray()) - throw new IllegalArgumentException("Property '" + name + - "' is not indexed"); - return (Array.get(value, index)); + if (value.getClass().isArray()) + return (Array.get(value, index)); + else if (value instanceof List) { + return ((List)value).get(index); + } + else { + throw new IllegalArgumentException("Property '" + name + + "' is not indexed"); + + } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>