I don't think its possible The GWT compiler must know in advance the type
of objects that can appear within the List "entities" so it can generate the
serialization and deserialization JavaScript code. Likewise I doubt it can
serialize a field of type "Class", as the browser doesn't really have the
same sort of class representation as the server does.
You probably will need to define a different method for each type of object
the operation will be on, so its clear to the compiler what type T is, so it
can generate the necessary JavaScript. This is actually something of a
safety advantage; it allows you to define operations for only the things the
browser should be allowed to perform. For example, in my current
application there are some entities I do not want the browser to be able to
read or to write, and some I want it to read, but not insert. By defining
specific functions in the RPC interface for each operation that is permitted
I can restrict it to a limited set.
On Mon, Dec 8, 2008 at 07:15, chris_wesdorp <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I tried but did not succeed so maybe someone can help. Using GWT RPC
> for CRUD using serializable objects requires at least one or four
> methods per entity. If one method is used I can create a wrapper
> object like:
>
> public OrderAction {
> private String action; // get, create, update, delete
> private List<Order> list;
>
> // constructor, getters and setters
> }
>
> Or I can create four methods by defining a method for each of the CRUD
> actions. However, as the application will grow and I want the keep the
> RPC interface simple I am trying to do something like this.
>
> public CrudAction<T> {
> private String action; // get, create, update, delete
> private List<T> entities;
> private Class<T> type;
>
> // constructor, getters and setters
> }
>
> and the RPC interface is defined as
> public String doSomething(CrudAction<T> action);
>
> but I the only thing I get is
> [ERROR] Type 'my.package.gwt.serializable.GenericRequest' was not
> serializable and has no concrete serializable subtypes.
>
> Is this possible to serialize a generic class like this?
>
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---