commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rahul Akolkar" <rahul.akol...@gmail.com>
Subject Re: [Beanutils] Determine type of bean field
Date Thu, 01 Jun 2006 20:32:24 GMT
On 6/1/06, Frank W. Zammetti <fzlists@omnytex.com> wrote:
> On Thu, June 1, 2006 3:32 pm, Craig McClanahan wrote:
> >> 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.
>
> Excellent, thanks again!  If you'll permit me one last question? :)
>
> I have a String[] field "certs" on the bean I'm populating, and I have a
> List in the object trying to populate it.  I've tried:
>
> PropertyUtils.setProperty(obj, "certs", ((List)fieldValues).toArray());
>
> ...but that gets me a java.lang.IllegalArgumentException: argument type
> mismatch.  How does one populate an array?  And specifically, from a List?
>  I guess the setCerts(String[] vals) method doesn't match up with the
> Object[] that toArray() returns...
>
<snip/>

Have you tried:

((List)fieldValues).toArray(new String[0])

which offers control over the runtime type of the returned array, here
an array of Strings?

-Rahul


> Frank
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message