This is a continuation of the following discussion: http://groups.google.com/group/google-web-toolkit/browse_thread/thread/d5315f505810304a
I have the same issue, namely that I want to be able to specify (e.g. through an annotation like @JavaOnly) that certain methods in my shared POJOs are for the use of the server-side code only. My goal is to exploit polymorphism and avoid the "instanceof" keyword on the server side. To get into a little more detail, what I'm trying to do is use the Abstract Factory pattern to associate certain concrete classes in the server package (which perform SQL updates, for example) with their corresponding plain old Java objects, which are in the shared package. I define an abstract method in the shared parent class (getSQL() e.g.) and then each of the subclasses provides a concrete implementation, which returns a concrete object of a server-side class (all of which, in turn, implement a common interface). Needless to say, the getSQL() method cannot be translated into JavaScript, because it depends on strictly server-side classes and concepts. However, I still want to share the object (i.e., its data) between client and server through RPC. Unfortunately, GWT throws an error when creating the JavaScript because it cannot find the source code for the server-side classes. Two solutions were posed to this problem in the previous discussion, but neither of them are helpful. The first was to simply wrap the method body in a "!GWT.isClient()" conditional, but since the method definition includes references to server-side code (its return type, specifically), nothing is actually hidden from the compiler. The second was to create subclasses of the shared objects on the server-side. Unfortunately, this method suffers from the same problem: the shared objects cannot know about their server-side counterparts. Thus, it doesn't really solve anything at all, because any operations would still require "instanceof" checking to obtain the correct server-side subclass. Another solution mentioned was to exclude certain classes in the module definition, but this method suffers from the same problem. So, is there a way to exclude a specific method (in an otherwise included class) from being compiled into JavaScript? Of course, if there's a better pattern that works with GWT, that would be helpful. Thanks, K. Bolino -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
