com.smartgwt.client.docs
Interface SpringIntegration


public interface SpringIntegration

Integration with Spring

Overview

The Spring framework has many different parts, from integration with Object Relational Mapping (ORM) and transaction management systems, to a Model View Controller (MVC) architecture.

If you are building a new application from scratch and/or you are trying to modernize the presentation layer of an existing application, most of Spring MVC is inapplicable in the 'Smart GWT architecture'. Specifically, Smart GWT renders all HTML on the client, and the server is responsible only for retrieving data and enforcing business rules. This means that Spring's ModelAndView and all functionality related to retrieving and rendering Views is unnecessary in Smart GWT. Smart GWT only needs the Model, and provides methods to deliver that Model to Smart GWT components (the server side method DSResponse.setData()).

However, Spring's DispatchServlet, Handler chain, and Controller architecture is applicable to Smart GWT. See "Using Spring Controllers" below.

Existing Spring Application

As discussed under the general 'server integration' topic, integrating Smart GWT into your application involves finding a way to provide data that fulfills the DSRequest sent by Smart GWT components.

There are 2 approaches for integrating Smart GWT into an existing Spring application:

Using Spring Controllers with Smart GWT DMI

You can create a Controller that invokes standard Smart GWT server request processing, including DMI, like so:


 public class Smart GWTRPCController extends AbstractController
 {
     public ModelAndView
 handleRequest(HttpServletRequest request, 
                                       HttpServletResponse response)

 throws Exception
     {
         // invoke Smart GWT server standard request processing
        
 com.isomorphic.rpc.RPCManager.processRequest(request, response);
         return null; // avoid default
 rendering
     }
 }
 
This lets you use Spring's DispatchServlet, Handler chain and Controller architecture as a pre- and post-processing model wrapped around Smart GWT DMI.