Announcement

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

    Smartgwt.mobile Request Method as POST

    Hello,
    We are using Smartgwt.mobile version 1.0 downloaded from the nightlies on the 17th Jan.

    We have existing smartgwt apps which are working perfectly and connecting to our server using REST methods.

    We would like to now connect a mobile app.
    Unfortunately our requests to the server are failing as the mobile Request Method is GET.
    In smartgwt we used the
    Code:
    setDataProtocol(DSProtocol.POSTMESSAGE);
    option.
    This is not in the mobile DataSource class. Is there a replacement or another way to set this?
    We have tried setting
    Code:
    dsRequest.setHttpMethod(RequestBuilder.POST);
    in the transform request method but this results in this error:
    Code:
    java.lang.UnsupportedOperationException: In setting the request data, failed to handle case protocol:GETPARAMS 	at 
    com.smartgwt.mobile.client.data.DataSource._sendGWTRequest(DataSource.java:1207) 	at 
    com.smartgwt.mobile.client.data.DataSource.sendDSRequest(DataSource.java:707) 	at 
    com.smartgwt.mobile.client.data.DataSource.performDSOperation(DataSource.java:683) 	at 
    com.smartgwt.mobile.client.data.DataSource.fetchData(DataSource.java:631) 	at 
    com.smartgwt.mobile.client.data.ResultSet.fetchServerData(ResultSet.java:176) 	at 
    com.smartgwt.mobile.client.data.ResultSet.getRange(ResultSet.java:343) 	at 
    com.smartgwt.mobile.client.widgets.tableview.TableView._refreshRows(TableView.java:1333) 	at 
    com.smartgwt.mobile.client.widgets.tableview.TableView.setData(TableView.java:1132) 	at 
    com.smartgwt.mobile.client.widgets.tableview.TableView.setData(TableView.java:1) 	at 
    com.smartgwt.mobile.client.widgets.DataBoundComponent._filterWithCriteria(DataBoundComponent.java:582) 	at 
    com.smartgwt.mobile.client.widgets.DataBoundComponent._filter(DataBoundComponent.java:565) 	at 
    com.smartgwt.mobile.client.widgets.DataBoundComponent.fetchData(DataBoundComponent.java:540) 	at 
    com.smartgwt.mobile.client.widgets.DataBoundComponent.fetchData(DataBoundComponent.java:534) 	at 
    com.ice.avalanchemobile.client.pages.AppointmentPanel.<init>(AppointmentPanel.java:45) 	at 
    com.ice.avalanchemobile.client.Client.runApp(Client.java:43) 	at com.ice.avalanchemobile.client.Client.startup(Client.java:33) 	at 
    com.ice.avalanchemobile.client.MainEntryPoint.onModuleLoad(MainEntryPoint.java:28) 	at 
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 	at 
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 	at 
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 	at 
    java.lang.reflect.Method.invoke(Method.java:601) 	at 
    com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:406) 	at 
    com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200) 	at 
    com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526) 	at 
    com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364) 	at
     java.lang.Thread.run(Thread.java:722)
    Is there a way of setting the Request Method to POST?

    When creating a GET method to test the mobile app, we are getting 415 Unsupported Media Type. Looking at the difference between the headers from a smartgwt request and a .mobile request we can see that the Content-Type:application/json is missing.
    When trying to set
    Code:
    dsRequest.setContentType("application/json");
    it doesn't seem to have any effect. Our REST services consume JSON. Again, all is working perfectly with smartgwt.

    Kind Regards,
    Jeni
    Last edited by jrich; 18 Jan 2013, 02:07.

    #2
    This has now been fixed, please grab tomorrow's nightly build.

    Comment


      #3
      Smartgwt.mobile Request Payload

      Hi Isomorphic,

      Thank you very much for your quick response. We are now able to access our REST services using POST methods.

      However, (sorry) the parameters for our REST methods are being received as null.

      I have attached two files, one is the header from the smartgwt app (smartgwt_header.txt) and the other is the one from the smartgwt.mobile app (mobile_header.txt).

      It seems that from the mobile_header the request payload
      Code:
      Request Payload
      {
          "dataSource":"ActivityCategoryDS", 
          "operationType":"fetch", 
          "startRow":0, 
          "endRow":75, 
          "textMatchStyle":"substring", 
          "componentId":"isc_ListGrid_0", 
          "data":{
          }, 
          "oldValues":null
      }
      is missing.

      The attached files are from the network tab of the developer tools in Chrome. Have we missed something?

      smartgwt.mobile version was downloaded today (20th).

      Kind Regards,
      Jeni
      Attached Files

      Comment


        #4
        We can't reproduce a problem with this - POST requests contain the expected data. If you're still experiencing this issue with the last nightly, please show runnable code that reproduces the issue, and we'll take another look.

        Comment


          #5
          Hi Isomorphic,
          Thank you for looking into this.
          I have done a couple of tests and your are right, the POST information is as expected if you have a critiera,

          Code:
          AdvancedCriteria criteria = new AdvancedCriteria("categoryName", OperatorId.EQUALS, "test");
                  
                  tableView.setDataSource(AppointmentDS.getInstance());
                  tableView.fetchData(criteria, new DSCallback() {
          ...
          or if you do a fetch with a criteria created with the blank constructor
          Code:
          tableView.fetchData(new AdvancedCriteria(), new DSCallback() {
          ...
          but, if you do the fetch with a null criteria then the POST data is null
          Code:
          tableView.fetchData(null, new DSCallback() {
          ...
          typically the portion of our smartgwt client code that was used to try out the mobile app was the third, where it works fine! If this is how it is meant to be, great we can change the fetches to include a blank criteria that's not a problem.
          Thanks again,
          Jeni

          Comment


            #6
            We've now fixed the issues that come up with POST if the criteria is specified as null.

            Comment


              #7
              Thank you very much, will grab the latest nightly.
              Jeni

              Comment

              Working...
              X