commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <fzli...@omnytex.com>
Subject Re: [Beanutils] Determine type of bean field
Date Thu, 01 Jun 2006 20:34:22 GMT
I haven't, but that's probably the right answer (I was just noticing that
method too as your message came in).  It's a little extra work, now I have
to get the type of the array dynamically, but that sounds like the right
answer.  Thanks Rahul!

Frank

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Java Web Parts -
http://javawebparts.sourceforge.net
Supplying the wheel, so you don't have to reinvent it!

On Thu, June 1, 2006 4:32 pm, Rahul Akolkar wrote:
> 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
>
>


---------------------------------------------------------------------
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