Using external class in client code

11 views
Skip to first unread message

Tarelli

unread,
May 4, 2009, 12:55:23 PM5/4/09
to Google Web Toolkit, giovann...@gmail.com
Hi All,

I am trying to use an external class in my client side interfaces.
I added the myClass (which is a JDO persisted object) in a shared
package as the class will be shared between client and server.
I added in my .gwt.xml file <source path="shared"/> for the client to
be able to see the class, which is working.
The problem though is that myClass uses the

com.google.appengine.api.users.User

class and when I try to compile I get the error

[ERROR] Line 12: The import com.google.appengine cannot be resolved
[ERROR] Line 33: User cannot be resolved to a type

How can I make the appengine User class visible to the client so that
I get rid of that error?
Thanks in advance,
Matteo


Rajeev Dayal

unread,
May 4, 2009, 5:13:33 PM5/4/09
to Google-We...@googlegroups.com
Any code that must be shared between the client and the server must have all classes which it imports available on the client side. In this case, you cannot actually have a JDO class which imports server-side classes as a class that will be shared between the client and the server.

What you'll need to do is create a set of DTO objects which are used as a transport mechanism for the data between the client and the server. These DTO objects should not have any dependencies on your JDO classes; instead, your server code should instantiate a new DTO, and populate its fields with data from the JDO object.

There has been discussion about making JDO classes directly usable by GWT's RPC mechanism, but a definitive solution does not exist as yet. See the following thread for more information:

http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thread/3c768d8d33bfb1dc


http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thread/3c768d8d33bfb1dc
Reply all
Reply to author
Forward
0 new messages