Custom Serializable Class in GWT RPC Call

73 views
Skip to first unread message

Iacopo

unread,
Sep 10, 2011, 3:02:35 PM9/10/11
to Google Web Toolkit
Hi everyone,
i'm building an university project with GWT + AppEngine.
In my RPC implementation (in /rpc) i have the following method:

public String subscribeToService(SubscriptionData userData);

which is then implemented and declared in the Async interface.

The SubscriptionData is a class defined in /server/data which handles
the entity to be saved together with all its properties.
Its code is the following:

import com.google.appengine.api.datastore.Entity;
import com.google.gwt.user.client.rpc.IsSerializable;

public class SubscriptionData implements IsSerializable {

private String hashedEmailAddress;
private String nickname;
private String role;
private Entity storableData;

public void setRole(String role) {
//storableData.setProperty("role", role);
}

public String getRole() {
return role;
}

public String getEmailAddress() {
return hashedEmailAddress;
}

public void setEmailAddress(String emailAddress) {
this.hashedEmailAddress = emailAddress;
}

public String getNickname() {
return nickname;
}

public void setNickname(String nickname) {
this.nickname = nickname;
}

public Entity getEntity() {
return storableData;
}
}

I checked the RPC doc page and, if i got it right, "A user-defined
class is serializable if all of the following apply:
It is assignable to IsSerializable or Serializable, either because it
directly implements one of these interfaces or because it derives from
a superclass that does
All non-final, non-transient instance fields are themselves
serializable, and
As of GWT 1.5, it must have a default (zero argument) constructor
(with any access modifier) or no constructor at all."

My class has all of them (Entity implements isSerializable), but still
when i try and compile the code i get the following error:
[ERROR] Errors in 'file:'project position'/rpc/RpcServiceAsync.java'
[ERROR] Line 26: No source code is available for type
'project name'.server.data.SubscriptionData; did you forget to inherit
a required module?

where in line 26 i have the following:
public void subscribeToService(SubscriptionData userData,
AsyncCallback<String> callback);

What do i do wrong? Can i use my custom serializable class as a
parameter in an RPC call?

Thanks everyone!
Cheers
Iacopo

Y2i

unread,
Sep 10, 2011, 6:58:17 PM9/10/11
to google-we...@googlegroups.com
Is 'project name'.server.data.SubscriptionData in your source path?


Modules can specify which subpackages contain translatable source, causing the named package and its subpackages to be added to the source path. Only files found on the source path are candidates to be translated into JavaScript, making it possible to mix client-side and server-side code together in the same classpath without conflict. When module inherit other modules, their source paths are combined so that each module will have access to the translatable source it requires.

Iacopo

unread,
Sep 22, 2011, 6:45:50 AM9/22/11
to Google Web Toolkit
Thanks i managed to solve the problem simply adding the class to the
compiled Shared folde ;)

Thanks! :)

On Sep 11, 12:58 am, Y2i <yur...@gmail.com> wrote:
> Is 'project name'.server.data.SubscriptionData in your source path?
>
> http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjec...
>
> Modules can specify which subpackages contain translatable *source*, causing
> the named package and its subpackages to be added to the *source path*. Only
> files found on the source path are candidates to be translated into
> JavaScript, making it possible to mix client-side<http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasics.htm...>
>  and server-side<http://code.google.com/webtoolkit/doc/latest/DevGuideServerCommunicat...> code
Reply all
Reply to author
Forward
0 new messages