Re: AutoBean returning List

Wed, 08 Jan 2014 01:57:48 -0800

AutoBeans do not support polymorphism, even for "primitive" values; and 
yes, that means you cannot work with mixed-type arrays.
I think you could still work with your JSON object, but at a lower level: 
use Splittable instead of List<Object>.

On Wednesday, January 8, 2014 9:04:42 AM UTC+1, aditi wrote:
>
> have an autobean that returns List<Object>. The reason is the json key to 
> which the getListVal() is mapped is an array of string and Integer values.
> After filling the autobean, I am able to get the size of getListVal 
> properly but while iterating through the returned list, illegalArgument 
> Exception is thrown.
> If I change the return type as String and have only string values in json 
> key it works fine. Is there anything wrong have Object as return type in 
> Autobeans?
>  
> TestAutoBean.java :
>  
> public List<Object> getListVal();
>
> code while iterating the getListVal returned list and accessing the 
> elements  - 
>
> List<Object> values= getListVal();
> *System.out*.println("params size = "+values.size()); // this displays 
> correct value 
>
> String *s* ="";
>
> *for* (*int* i = 0; i< values.size(); i++)
>
> {
>
> s = (String)values.get(i); // This line throws 
> java.lang.IllegalArgumentException: java.lang.Object .
>
> }
>
> For the above case the json key has only String value.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to