Error creating Engine DataStore Entity app in GWT app

I am trying to create an entity like this:

DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Entity stock = new Entity("Stock", 1);
stock.setProperty("Stock", "FCB");
ds.put(stock);

      

but keep getting the error:

No source code for type com.google.appengine.api.datastore.DatastoreService; did you forget to inherit a required module?

+3


source to share


2 answers


Source code not available

GWT transliterates Java to Javascript by reading its source code and limited language support .

What you are trying to achieve is a Server operation , and you add this operation to the client code that will run in the browser. Neither GAE allows this, nor does GWT have the source of these classes and cannot do so.



Decision

You need to create a request to your server, which will contact DatastoreService

, return the result to the client code. Below is an example of a valid GWT architect web application: GWT Diagram

+1


source


The error only means what it says, the GWT compiler needs access to the Java source it compiles to Javascript and is obviously DatastoreService

not something that should exist on the interface, so you have an architecture problem.

You will need to write a proxy that can call the server component (which calls in turn DatastoreService

) and returns DTOs / value objects (which you define and therefore have a source).



Greetings,

+2


source







All Articles