(I posted this to the gwt-dispatch list, but figure I'd mention it here
too....larger audience and whatnot)

I am implementing the command pattern as per Ray Ryan's fantastic talk.   I
have it working, however I ran across a known issue in GWT when implementing
my servlet (Which Ray Ryan skips over in his talk :)  ).    If you implement
your actions/responses exactly as he has them in the slides, your servlet
won't work, due to what appears to be a bug in the GWT (issue 2374).
Basically, the wrong code gets generated due to the use of templates, and
when the servlet tries to match up the required methods in the service, it
can't find your execute method, even though you have implemented it.

I worked around it like so:

(in my rpcserviceimpl.java)
public <T extends Response> T execute(Action<T> action)
{
 if (action.getClass().equals(MyActionClass.class) )
     return (T) execute( (MyActionClass) action );

 // actually I throw if i get here, but to keep this short....
 return null;
}

Obviously, not type safe, but if my action class matches, then the return
type better be MyActionResponse or I have a bigger issue!

I noticed another command pattern implementation on google code that worked
around this issue by passing the action class in an annotation, however I
couldn't tell from that code if that workaround/hack was any better than
mine above.

Would using the annotation make it type safe? Is what I have the best work
around for now?   Is this working on trunk GWT 2.0?    Is there a different
work around I am not seeing?

-pj

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to