views:

78

answers:

3

First of all,

many thanks to Craig for the excellent answer below which I found very useful when searching my original issue... ref: http://stackoverflow.com/questions/2237142/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

+1  A: 

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
+1  A: 

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
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
A: 

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