On Thu, Oct 16, 2008 at 2:26 PM, Suri <[EMAIL PROTECTED]> wrote:
> I'm trying to write a service that will return objects to be used at
> the client side. I understand that I'll need to create transfer
> objects essentially implementing the isSerializable interface so that
> GWT can correctly compile and use them. Since, I'm aware that only
> primitive types or wrappers of primitive types and collections of
> these can be passed along or custom classes that only have such
> instance variables, my question is this:
>
> If I have 2 objects
>
> X implements isSerializable
>  - int
>  - String
>  - HashMap<String, String>
>
> Y implements isSerializable
>  - int
> - String
> - List<X>
>
> Can Y be passed successfully using the GWT RPC mechanism?

You have some false assumptions:

- As of GWT 1.4 you can forget about IsSerializable--just use
java.io.Serializable.

- Given that you can use the standard Serializable marker interface,
you might not have to create transfer objects--it depends on what your
non-transfer-object classes look like.  (I do have to use client-side
versions of my entity beans because I rely on BigDecimal on the server
for currency values and GWT doesn't support BigDecimal but, if not for
that incompatibility, I could probably use my entity beans directly.)

- You can serialize almost anything that's serializable by the
standard definition in Java.  One additional restriction is that there
has to be a client-side implementation of the concrete runtime type
that you're trying to serialize.  This causes grief for some people
using, for example, Hibernate's persistent collection classes because
they're not translatable.  Another restriction is that not everything
that implements Serializable in the standard JRE implements
Serializable in the emulation library.  For example, until recently
TreeMap was not serializable (it's been fixed, but I'm not sure what
the status of the patch is).  Finally, Throwable implements
Serializable but, for performance and space reasons, exceptions thrown
on the server will not serialize the .cause member because doing so
would require including implementations of every conceivable exception
type on the client "just in case".

To directly answer your question, both Y and X are serializable
according to GWT.

Ian

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to