Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Spring Controllers chain and SmartGWT

    Hi there,
    After some time (quite a lot, to be honest, about two years) spent on LGPL version, I'm evaluating EE/Pro of SmartGWT (for a quite complex project, for which LGPL won't be suitable).
    Following the online and bundled documentation I succesfully used Spring mappings with Datasource CRUD related operation (binding to "client" objects), but I don't well understand the section:

    Code:
    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.
    How can I bind Controllers processing to user request (if i could)?
    I miss something?

    Basically, I would (I need) to "modularize" the most possible the server code, and I'm wondering if there is a way to integrate Spring Controllers into server processing method, I mean:
    1) Into "client" I invoke methods from stadards mapping async services;
    2) Related "Implementation" aren't standard Impl classes but Controllers (Spring mapped), from which I could call other beans, complete the processing and return response data to client Callback;

    Any hint?

    Thanks a lot,

    Luca.

    #2
    This would be a second or third choice of integration strategy. Instead, start by looking at whether built-in DataSource types can call your existing JPA/HB entities or SQL tables; in any cases where that doesn't work, consider calling existing Java service logic via DMI. Avoid integration with Controllers if possible as those are pieces of an older Spring MVC architecture that is designed for server-side HTML generation.

    Comment


      #3
      Thanks Isomorphic,
      I'll take a look into these ways.

      I just use built-in DS functionalities (XML datasource definition, Spring lookup and hibernate sub-layer), to manage data flow form client to server (and vice-versa), but I need "extra" server methods (not strictly "data" related) for other pourposes and I like the option to (eventually) add beans and other sub-process into application workflow, taking no care of flow itself.

      Only few minutes ago I understand what was wrong. I was mixing GWT-RPC and Spring Controller logic. Cut off all GWT-RPC and try directly with RPCManager plus Spring mappings (via annotation ATM) and now, all works like a charm.

      Thanks again for the advice,


      Luca.

      Comment


        #4
        Right. Also as a further note, for non-CRUd operations consider DataSource.performCustomOperation(), or, if you prefer the operation is not associated with a DataSource at all, RPC DMI (see DMI overview).

        Comment

        Working...
        X