3

First of all,

many thanks to Craig for the excellent answer below which I found very useful when searching my original issue... ref: GWT Simple RPC use case problem : Code included

Building on this solution, how does one overcome the (seemingly GWT limitation) where if i leave my persistable object in /shared folder as Craig suggests... and annotate it as GWT tutorials suggest...

@PersistenceCapable
public class Employee {

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;

GWT is seemingly unable to deal with / import the com.google.appengine.datastore.key on the client side?

I have seen a few ugly hacks...but nothing elegant.

Any suggestions welcome, Thanks

Community
  • 1
  • 1
Will
  • 33
  • 3

4 Answers4

3

Unfortunately, App Engine's Key class (and others) are not GWT-compatible. This means that you have to retrieve an object from the datastore, then translate it into a GWT-compatible POJO to send over GWT-RPC to the client.

I suggest looking into using the objectify framework for App Engine. Not only is it a much simpler interface into the datastore, but the persistent objects it uses are GWT-compatible, so you can send them over GWT-RPC to your client.

Jason Hall
  • 20,632
  • 4
  • 50
  • 57
2

You can use the Key class in GWT code by adding these additional jar files:

http://www.resmarksystems.com/code/

  • appengine-utils-client-1.0.jar
  • appengine-utils-server-1.0.jar

This basically gives the GWT compiler a GWT-friendly version of the Key and other AppEngine classes. (like Text, Blob and User..)

To use:

  • Add the appengine-utils-client-1.0.jar anywhere in your build path.
  • Put the appengine-utils-server-1.0.jar to your WEB-INF/lib folder.

In your GWT module add the following:

<inherits name="com.resmarksystems.AppEngineDataTypes"/>
Nick Siderakis
  • 1,961
  • 2
  • 21
  • 39
  • Hi, resmarksystems libraries deal with Key, Text, ShortBlob, Blob, Link, User, PostalAddress, PhoneNumber and Rating. Is there a way to deal with com.google.appengine.api.datastore.GeoPt in the same context (RPC, persistent Java objects)? – Michaël Oct 12 '10 at 18:44
0

If you don't need the Key object for something your key can be a Long or String which are easily serializable and thus work with standard GWT-RPC.

Datastore keys

Rikard
  • 399
  • 3
  • 14
0

I think Google has just released a GWT library called requestfactory for this use-case. This is the link

Daghan ---
  • 1,147
  • 1
  • 9
  • 10