title: Smartgwt with RestDataSource and SpringController
body: <p>I have been stuck at this for a while. I have a smartgwt widget listgrid tied to a restdatasource. I have mapped its URLs to my spring services. However I cannot figure out how to retrieve the JSON dsrequest on spring server side. Even my dispatcher servlet does not contain the params.</p>
  
  <p>My restdatasource is as follows:</p>
  
  <pre><code>RestDataSource myDS = new RestDataSource() {  
                  @Override  
                  protected Object transformRequest(DSRequest dsRequest) {
                      dsRequest.setContentType("application/json");
                      JavaScriptObject jso = dsRequest.getData();
              String s1 = JSON.encode(jso);
              return s1;
  //                  return super.transformRequest(dsRequest);  
                  }  
                  @Override  
                  protected void transformResponse(DSResponse response, DSRequest request, Object data) {  
                      super.transformResponse(response, request, data);  
                  }  
              };
  </code></pre>
  
  <p>Then on this datasource set the operations as follows:</p>
  
  <pre><code>// set the operation on the datasource  
              OperationBinding fetch = new OperationBinding();  
              fetch.setOperationType(DSOperationType.FETCH);  
              fetch.setDataProtocol(DSProtocol.POSTMESSAGE);  
              OperationBinding add = new OperationBinding();  
              add.setOperationType(DSOperationType.ADD);  
              add.setDataProtocol(DSProtocol.POSTMESSAGE);  
              OperationBinding update = new OperationBinding();  
              update.setOperationType(DSOperationType.UPDATE);  
              update.setDataProtocol(DSProtocol.POSTPARAMS);  
              OperationBinding remove = new OperationBinding();  
              remove.setOperationType(DSOperationType.REMOVE);  
              remove.setDataProtocol(DSProtocol.POSTMESSAGE);  
              myDS.setOperationBindings(fetch, add, update, remove);
              myDS.setDataFormat(DSDataFormat.JSON);
  //          myDS.setDataProtocol(DSProtocol.POSTMESSAGE);
  </code></pre>
  
  <p>Set some fields in the datasource:</p>
  
  <pre><code>// set the values for the datasource
              DataSourceTextField Id = new DataSourceTextField("Id", "Id");
              Id.setPrimaryKey(true);  
              Id.setCanEdit(false);  
              DataSourceTextField name= new DataSourceTextField("name", "Name");
              name.setCanEdit(false);
              DataSourceTextField employeeType= new DataSourceTextField("employeeType", "employeeType");
              employeeType.setCanEdit(true);
              employeeType.setValueMap("Manager", "Associate", "Contractor");
  </code></pre>
  
  <p>Set these fields to the datasource:</p>
  
  <pre><code>myDS.setFields(Id, name,employeeType);  
  myDS.setFetchDataURL("/rest/myservice/fetch");  
  myDS.setAddDataURL("/rest/myservice/add");  
  myDS.setUpdateDataURL("/rest/myservice/update");  
  myDS.setRemoveDataURL("/rest/myservice/remove");
  </code></pre>
  
  <p>So in the case that the user changes the employeeType (because it's a dropdown), an update request is sent. I send the JSON string to the server configured as below:</p>
  
  <pre><code>@Controller
  @RequestMapping("/myservice")
  public class MyService {
  ...fetch
  ...update
      @RequestMapping(value="/update", method=RequestMethod.POST)
      @ResponseBody
      public String update()
      {
           }
  </code></pre>
  
  <p>I am failing to understand how to retrieve the (JSON) dsrequest because even my DispatcherServlet does not have the parameters (even if I use POSTPARAMS). The developer console shows the request made correctly but I don't receive anything on the server side.
  My spring servlet is configured as below in web.xml:</p>
  
  <pre><code>&lt;servlet&gt;
  &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
  &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;    &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>I think I am missing something obvious but I can't locate it. Do I use @PathVariable or RequestParams?</p>