Announcement

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

    Strange difference when running locally versus compiled version

    I'm calling a custom operation binding and passing a simple Record with three attributes set, all of which are Strings. Here is what I see on the server when running locally. Everything looks fine.
    Code:
    === 2010-07-11 17:53:21,508 [0-57] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        values:{
            IONO:"00000JAM10",
            ItemNumber:"100-1-1",
            IPPK:"N"
        },
        operationConfig:{
            dataSource:"PoItem",
            operationType:"custom"
        },
        appID:"builtinApplication",
        operation:"getDefaults",
        oldValues:{
            IONO:"00000JAM10",
            ItemNumber:"100-1-1",
            IPPK:"N"
        },
        criteria:{
        }
    }
    And when I compile and run the resulting war in Tomcat I see the following, where the ItemNumber attribute looks like an array or map instead of a String. ??
    Code:
    === 2010-07-11 15:35:33,099 [85-5] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        values:{
            IONO:"000BEAUTY8",
            ItemNumber:{
                "0":"1",
                "1":"0",
                "2":"0",
                "3":"-",
                "4":"1",
                "5":"-",
                "6":"1",
                tI:2
            },
            IPPK:"N"
        },
        operationConfig:{
            dataSource:"PoItem",
            operationType:"custom"
        },
        appID:"builtinApplication",
        operation:"getDefaults",
        oldValues:{
            IONO:"000BEAUTY8",
            ItemNumber:{
                "0":"1",
                "1":"0",
                "2":"0",
                "3":"-",
                "4":"1",
                "5":"-",
                "6":"1",
                tI:2
            },
            IPPK:"N"
        },
        criteria:{
        }
    }
    I'm running the latest nightly with GWT 2.0.3.

    #2
    This is a core GWT that has to do with how Strings are handled, and can usually be fixed by explicitly calling toString() on an object that is already clearly of String type. So look in the code for where you are passing ItemNumber to some Smart GWT API and call toString() there (and please let us know if there's a reproducible case you can share).

    Comment


      #3
      I changed the line that sets the attribute to requestData.setAttribute("ItemNumber", itemNumber.toString()); but I'm still getting the same error. Again, not locally, but only when compiled and deployed to Tomcat. ?

      Comment


        #4
        What is the type of itemNumber originally? The GWT issue actually arises when .toString() is called directly or indirectly so try changing your code to

        requestData.setAttribute("ItemNumber", itemNumber + "");

        This will coerce the String type to be treated as a JS String primitive and should work around the issue.

        Sanjiv

        Comment


          #5
          Thanks so much for the tip. That did take care of it. It is an odd problem since the String in question is declared as a String and never anything but a String just like the other Strings being passed. I can't see what the difference is, but if I do discover one I'll let you know. Thanks again.

          Comment


            #6
            A String constructed as a new String("..") will also trigger this.

            Make sure you vote for that issue by "starring" it.

            Sanjiv

            Comment


              #7
              It is constructed originally as String itemNumber = "";

              Afterwards it is set from the contents of a TextItem via

              itemNumber = poItemEditForm1.getField("ItemNumber").getValue().toString();

              Is it better to cast TextItems to a String rather than use toString?

              Comment


                #8
                Yes, as indicated in the GWT issue casting the value to a String does not trigger this issue.

                Comment

                Working...
                X