commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig McClanahan" <craig...@apache.org>
Subject Re: [Beanutils] Determine type of bean field
Date Thu, 01 Jun 2006 19:32:53 GMT
On 6/1/06, Frank W. Zammetti <fzlists@omnytex.com> wrote:
>
> Next question :)  Because it's related to what I'm doing with the first, I
> figured go with the same thread...
>
> I have an instance of the Test class, which contains the following:
>
> private List children;
> public void setChildren(final List inChildren) {
>   children = inChildren;
> }
> public List getChildren() {
>   return children;
> }
>
> Then, in a class trying to populate this, I have:
>
> Object obj = new Test();
> List fieldValues = new ArrayList();
> fieldValues.add("test");
> PropertyUtils.setIndexedProperty(obj, "children", fieldValues);
>
> When I try it, I get:
>
> java.lang.IllegalArgumentException: Invalid indexed property 'children'
>
> Not sure what's going on... since this is the version of
> setIndexedProperty() without the index, I assume it's going to call
> setChildren(List) and not be looking for the setter with the index,
> correct?  Thanks!


Correct.  It's a limitation of BeanUtils that it does not try to use the
"indexed" setters if they exist.  It only deals with the actual List or
array property as a whole.

Frank


Craig

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message