Friday, December 10, 2010

Re: sending Polymorphic types from Server to GWT client

Hi,

It's possible: did it several times.

The key is to use GWT-RPC (instead of JSON, xml, etc..) in order to
preserve all the Java structure between client and server.

How ?
a) You will define Foo, Bar, Baz in the "shared" folder of project
structure so that they know on both sides

b) you will define either 1 generic RPC query/request for the 3 object
types (easy if you have a parent class on top of your 3 classes) or 1
RPC query/request per object type.

c) GWTRPC will deliver those objects as Java objects (when you code)
so you can use then "instance of".

To make things simpler, you can even use the RequestFactory of GWT 2.1

Preserving Java semantics end-to-end is for me the best part of GWT:
you can leverage the power of object hierarchies, interfaces, etc. in
your front-end. The simplest way to achieve this is GWTRPC that allows
transparent transport of objects between client and server.

regards
didier


On Dec 10, 11:00 pm, zixzigma <zixzi...@gmail.com> wrote:
> I have three objects, that implement a base interface and reside on
> the server.
>
> interface Base
> class Foo implements Base
> class Bar implements Base
> class Baz implements Base
>
> I want to send them over the wire to GWT client.
>
> would GWT recognize the relationship they had ?
>
> I want to use them in CellTree: NodeInfo
> and would like to do something like
>
> if (value instance of Foo)
> ///
>
> if(value instance of Bar)
> ///
>
> if(value instance of Baz)
> ///
>
> is this possible ?
> how ?

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate