Tuesday, August 30, 2011

Re: Help! Some confusing problems about gwt rpc with generics!

http://code.google.com/p/google-web-toolkit/issues/detail?id=2374


On 30/08/11 08:10, Lan Andrew wrote:
> Thank you very much,Alex.
>
> Yes,maybe I shouldn't send List over rpc and use generics in gwt rpc
> like this way.
> But I also have some problems about the exception above.
> The generic parameter K would be still erased in the generated Proxy
> implementing that interface,even though I bind the parameter type,such
> as String, in the subinterface, which will be used in the app client
> page. Right?
> As it happens when I call the second function T callServer(K id), I am
> not sure whether it means the gwt rpc doesn't support the generics?
> Or it is just a bug?
>
> Thanks again.
>
> On 8月29日, 下午3时18分, Alex Dobjanschi<alex.dobjans...@gmail.com> wrote:
>> Are you sure you need a generic RemoteService? Like Jeff stated, RPC
>> proxyCreator needs to ensure all subtypes of the types specified in your
>> RemoteService need to be serialized (that way, server& client can
>> communicate without problems). This will bloat the size of generated code.
>> Moreover, having T& K can only reduce the code-size by 100 bytes or so,
>> like this:
>>
>> public interface GenericsRpcService<T,K> extends RemoteService{
>> T callServer(List<K> id);
>> T callServer(K id);
>>
>> }
>>
>> *public interface UserRpcService extends GenericsRpcService<User, Long> {*
>> * // Other (additional methods).*
>> *}*
>> *
>> *
>> Notice the 2 methods from GenericsRpcService are already present in the
>> subinterface. This is the only advantage you can get. Besides, you need a
>> type literal for *GWT.create *so there's no way to call *GWT.create
>> (GenericRpcService<A, B>.class) *(same goes with dependency injection -- you
>> can't bind a generics interface).

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment