I would like to incorporate a GWT front-end into a Spring application. This Spring application will have several different kinds of views. GWT will be only one of them.
Given this requirement, it would be nice to decouple the GWT from the server-side code. The GWT Http Request Classes in com.google.gwt.http.client look like an attractive alternative to RPC.
I am a GWT newbie. Perhaps I am not understanding what RPC does. But I ask, for the sake of drawing out the issue,
Why would one ever want to use GWT RPC? Why would not one want always want to use the Http Client classes, in order to decouple server-side code from client-code, with plain Java controller code on the server not wedded to GWT specifics?
or, if the RPC code is necessary, what would be the best way to encapsulate it in this multiple view-style Spring application? Put it into a "GWTController"?
Any suggestions or comments are welcome!
Thanks in advance.
Joined: Apr 08, 2003
...or, continuing my second question, if RCP is necessary, why not redirect from Spring Dispatcher Servlet--not to a Controller, but to another servlet, a GWTServlet?
Write a servlet on server side. Everything works like a magic. This is what a GWT RPC gives you. All your client UI code does is get java objects from the GWT Servlet and work with java objects. You wouldn't need to handle HTTP requests, parsing the data or json format or anything else. Your client code remains a pure java code working with java objects alone.
GWT Servlet takes care of translating java objects which are transported to client side, as http requests automatically. So, you need not bother.
Now then, to plugin into spring; yes it is like as you mentioned. For certain views(url patterns), redirect the requests in spring to gwt guy. If you look at how to implement your gwt servlet for RPC, you will know that, the servlet is configured to serve a paritular url pattern.
Joined: Apr 08, 2003
Thanks, Prabakar, you remind me of the benefits of using a servlet. As you say a servlet allows you to work with Java objects and I don't have to worry about httpRequests, formatting, Jason, etc.
And thanks for the confirmation about how to use GWT in Spring. I will approach the problem with more confidence.