Wednesday, January 27, 2010

Using Spring with GWT (Google Web Toolkit)

Hi All,
I have been working on the Google web toolkit (GWT) technology version 1.6 lately. We had a task at hand to integrate server side spring technology and use GWT at the client side. GWT is an AJAX based framework developed by google and all the server side calls are processed through AJAX. The catch here is since GWT dispatches only RPC calls to the server. To integrate spring framework, an external library gwt-sl-0.1.5b.jar  was used in which we have a support package for spring integration. This discovery helped us to solve most of out problems. A GWTHandler class was used to handle the RPC requests from the GWT client.
This class is mapped in the spring-servlet file on the server side as follows:


     < bean class="org.gwtwidgets.server.spring.GWTHandler" >
          < property name="mappings" >
              < map >
                      < entry key="/module/myTestModule/test.rpc" 

                                   value-ref="test" / >
              < / map >
          < / property >
       < / bean > 


Prior to using this method, the service classes on the server side used to extend from the RemoteServiceServlet class. But using this mapping I could avoid extending from any classes and hence keeping the class free to extend from any other application specific classes.