Announcement

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

    RestDataSource passes null values as "null" strings?

    Hey,

    I stumbled upon an issue, where the ValuesManager.getValues() returns the following:

    {"title"="VALDZHIA", "code"="ADMINISTRATION", "roles"=null, "_id"="UG0", "_lastUpdated"=null, "_action"="UPDATE", "_selection_10"=true}

    note the _lastUpdated and roles - they are both null.

    Now, the request being passed to the server, ends up converting null values to "null" strings, which kinda breaks my stuff:

    Code:
    {
        dataSource:"UG", 
        operationType:"update", 
        componentId:"isc_ValuesManager_2", 
        data:"{\r    \"dataSource\":\"UG\", \r    \"operationType\":\"update\", \r    \"componentId\":\"isc_ValuesManager_2\", \r    \"data\":{\r        \"title\":\"VALDZHIA\", \r        \"code\":\"ADMINISTRATION\", \r        \"roles\":\"null\", \r        \"_id\":\"UG0\", \r        \"_rev\":\"8-6fcd425a62fa872eb6bac5c8b4251a86\", \r        \"_lastUpdated\":\"null\", \r        \"_action\":\"UPDATE\", \r        \"_selection_10\":true\r    }, \r    \"oldValues\":{\r        \"title\":\"VALDZHIA\", \r        \"code\":\"ADMINISTRATION\", \r        \"roles\":[\r            \"PRICING_MANAGER\"\r        ], \r        \"_id\":\"UG0\", \r        \"_rev\":\"8-6fcd425a62fa872eb6bac5c8b4251a86\", \r        \"_lastUpdated\":\"null\", \r        \"_action\":\"UPDATE\", \r        \"_selection_10\":true\r    }\r}", 
        callback:{
            target:[ValuesManager ID:isc_ValuesManager_2], 
            methodName:"saveEditorReply"
        }, 
        showPrompt:true, 
        prompt:"Saving form...", 
        oldValues:{
            title:"VALDZHIA", 
            code:"ADMINISTRATION", 
            roles:[
                "PRICING_MANAGER"
            ]
        }, 
        requestId:"UG$6278", 
        clientContext:{
        }, 
        fallbackToEval:false, 
        afterFlowCallback:"isc_ValuesManager_2.$49z(dsRequest, dsResponse, data)", 
        editor:[ValuesManager ID:isc_ValuesManager_2], 
        bypassCache:true, 
        isRestRequest:true, 
        dataFormat:"json", 
        contentType:"application/json"
    }
    I am using latest nightly of 3.1d:
    SmartClient Version: SNAPSHOT_v8.3d_2012-10-12/LGPL Development Only (built 2012-10-12)

    Am I missing something, like some flag on datasource?At the moment I'm using:

    Code:
            restDataSource.setDataFormat(DSDataFormat.JSON);
            OperationBinding update = new OperationBinding();
            update.setOperationType(DSOperationType.UPDATE);
            update.setDataProtocol(DSProtocol.POSTMESSAGE);
    Any pointers would be much appreciated!

    regards,
    Andrius

    #2
    just some additional, better formatted info. browser post ends up looking like this:

    Code:
    { "dataSource":"UG", "operationType":"update", "componentId":"isc_ValuesManager_1", "data":{
        "title":"VALDZHIA",
    -------------------------------------------
        "code":"null",
        "roles":"null",
    -------------------------------------------
        "_id":"UG0",
        "_rev":"15-a5980ebc2b6a8a49f9dcd56887715d8f",
        "_lastUpdated":1350422982170,
        "_action":"UPDATE",
        "_selection_10":true
    }, "oldValues":{
        "title":"VALDZHIA",
    -------------------------------------------
        "code":"ADMINISTRATION",
        "roles":[ "PRICING_MANAGER" ],
    -------------------------------------------
        "_id":"UG0",
        "_rev":"15-a5980ebc2b6a8a49f9dcd56887715d8f",
        "_lastUpdated":1350422982170,
        "_action":"UPDATE",
        "_selection_10":true
    } }
    The 'code' field was being mapped to a simple TextInput field in a dynamic form, so posting it as "null" string instead of null JSON element looks like a bug - unless I am missing something obvious?

    regards,
    Andrius

    Comment


      #3
      There are a number of processing steps at which a null value could become the string null. We need to see runnable code in order to see whether this is a bug or just invalid usage.

      Comment


        #4
        Hello again,

        https://bitbucket.org/phuqit/smartgwt-restdatasource-issues/src

        here's a very simple test case that proves the issue is not imaginary.
        1. Open firebug net console,
        2. Enter anything into the ID text field,
        3. Delete the text,
        4. Press the save button.

        Firebug shows the following being posted:

        Source
        { "dataSource":"wtatever", "operationType":"add", "componentId":"isc_DynamicForm_0", "data":{ "id":"null" }, "oldValues":{ } }

        Hope this helps,
        Andrius

        Comment


          #5
          Thanks for the update. We'll take a look

          Comment


            #6
            We've made a change which should resolve this issue (available in the 3.1 branch)

            Regards
            Isomorphic Software

            Comment


              #7
              Good news, thanks! I don't see any changes made in smartgwt repository on googlecode - should I just wait for latest nightly?

              regards,
              Andrius

              Comment


                #8
                Still seeing the same behavior in the latest nightly:

                SmartClient Version: v8.3d_2012-10-17/LGPL Development Only (built 2012-10-17)

                Should I manually upgrade smartclient lib?

                Comment


                  #9
                  We're not sure what you mean by "manually upgrade smartclient lib", but there are instructions in the FAQ for making sure you're really using the updated version. Mistakes like forgetting to run a GWT compile or not clearing the browser cache can mean you are still using the old version after attempting an upgrade.

                  Comment


                    #10
                    Assuming smartgwt is being developed using googlecode @ http://code.google.com/p/smartgwt/source/list, I didn't see any relevant commits, neither did I see the functionality change in the latest nightly.

                    The "SmartClient Version: v8.3d_2012-10-17/LGPL Development Only (built 2012-10-17)" was copied from smartgwt debug console, so I am pretty sure I am using the correct version in my application.

                    Am I missing something?

                    regards,
                    Andrius

                    Comment


                      #11
                      smartclient.com/builds has the true nightlies. GoogleCode gets updated less frequently to avoid too many build failures and the like.

                      Comment


                        #12
                        I think you want the 10/18 build

                        Comment


                          #13
                          Very cool guys, the 10/18 build actually works. Thanks a million!

                          regards,
                          Andrius

                          Comment

                          Working...
                          X