Is this 'concrete type' als valid for a DTO object in GWT-RPC?

For example, I have a TestDTO object, which needs to be transferred via 
GWT-RPC.







*public class TestDTO implements IsSerializable {         public 
ArrayList<String> data;         public List<String> operation() {           
      return null;         }}*

If I understand correctly, data field needs to be a concrete type. How 
about the method operation, can I return here a generic List interface?

Best regards,

Hua


On Thursday, January 26, 2012 at 2:57:33 PM UTC+1 [email protected] wrote:

>
>
> On Thursday, January 26, 2012 1:58:14 PM UTC+1, tanteanni wrote:
>>
>> at the beginning of my gwt adventure i read somewhere that it is better 
>> to use concrete classes for interfaces like lists, because the gwt compiler 
>> must generate java script for every kind of list.
>> Is this (still) true?
>>
>
> Only on GWT-RPC, and yes it's still true. If you say 
> you're transferring SomeObject via RPC, GWT has to compile the code for 
> every class it knows that extends SomeObject, so you can safely send and 
> receive SomeOtherObject (provided "class SomeOtherObject extends 
> SomeObject"). So if you say java.util.List, GWT will grab 
> java.util.Collections.SingletonList, java.util.Collections.EmptyList, 
> java.util.Collections.ImmutableList, java.util.Arrays.ArrayList, 
> java.util.ArrayList, java.util.LinkedList, etc. whereas if you say 
> java.util.ArrayList, it reduces the number of classes that you app has to 
> know about.
>
> You can safely use java.util.List everywhere else in your code, just not 
> in your method declarations in your GWT-RPC interfaces.
>
> BTW, AutoBeans and RequestFactory only allow java.util.List and 
> java.util.Set (and java.util.Map for AutoBeans), not java.util.ArrayList, 
> java.util.HashSet or java.util.HashMap for instance.
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/c8f74a64-9031-49a5-860a-c1ce2c472e43n%40googlegroups.com.

Reply via email to