2

I'm using GWT-GAE and faced a bad issue dealing with RPC Can't use Entity Classes on the Server Side within the Client Side

I checked this first answer for that question [here]

but the solution will cause other errors and It's too hard to Implement

So is that a problem to Import server side classes into Client Side classes cuz there is a guy said in the link included above he said : There are a couple of things to keep in mind about GWT: Server-side classes can import client-side classes, but not vice-versa (usually). The client-side can't import any Google App Engine libraries (i.e. com.google.appengine.api.users.User)

is that true if so how to overcome this problem I have to use server side classes in the client interface

Hint: I'm Using JDO and No-SQL database (GAE Datastore)

Thanks in Advance

Community
  • 1
  • 1
Youans
  • 4,801
  • 1
  • 31
  • 57

2 Answers2

3

What that quote means is that any code you send to the client through RPC must be converted to Javascript. Thus, any Java constructs or libraries that cannot be converted to Javascript, will not work on the client. Any code that works in the client will (should) work on the server because it's still just Java, and code ran in the server doesn't need to be converted into its equivalent in Javascript, thus that restriction does not apply.

As far as helping you with your particular problem, we'll need some more specific information regarding any issues you're facing. Typically what you want to send down through an RPC is an object that simply transports your model data to the client, where the data can be used. This is especially so when your model uses code in the server that cannot be converted to Javascript.

In other words, if your entity class uses some server specific code, you'll need to leave that code in the server, and only send the data to your client, along with any cod that you'll need there, but that can indeed be sent to the client. This is a good distinction between GWT RPC and the newer RequestFactory, which is probably what you'll need if that's the problem you're facing.

rodrigo-silveira
  • 12,607
  • 11
  • 69
  • 123
  • So if I'm using RPC I will face Java-JavaScript Problem otherwise **RequestFactory** is a Good Solution – Youans Feb 12 '13 at 06:06
0

With http://code.google.com/p/objectify-appengine/ you can put your entity classes into <source path='client'/> or <source path='shared'/> (e.g. on the server-side you can load the Stock from the database and send it "as is" to the client; then on the client you can modify the Stock or create a new one and send it to the server).

ArtemGr
  • 11,684
  • 3
  • 52
  • 85