Reputation: 33
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
Upvotes: 3
Views: 1670
Reputation: 1147
I think Google has just released a GWT library called requestfactory for this use-case. This is the link
Upvotes: 0
Reputation: 409
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.
Upvotes: 0
Reputation: 1961
You can use the Key class in GWT code by adding these additional jar files:
http://www.resmarksystems.com/code/
This basically gives the GWT compiler a GWT-friendly version of the Key and other AppEngine classes. (like Text, Blob and User..)
To use:
In your GWT module add the following:
<inherits name="com.resmarksystems.AppEngineDataTypes"/>
Upvotes: 2
Reputation: 20920
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.
Upvotes: 3