Announcement

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

    The getErrors method of DSResponse

    JSON Structure as below:
    Code:
    {
      "response":{
        "status":-1,
        "startRow":0,
        "endRow":0,
        "totalRows":0,
        "errors":{"SQL":"SQL Syntax ERROR"},
        "data":[]
       }
    }
    and in MyRestDataSource class, the method transformResponse as below:
    Code:
    protected void transformResponse(DSResponse response, DSRequest request, Object data) {
         Map errors = response.getErrors();
         if(errors != null && errors.size() > 0 ){
    	 Window.alert(errors.get("SQL").toString());
         }
         super.transformResponse(response, request, data);
    }
    But errors' size is 0, seems like the DSResponse didn't get error message from JSON data.

    Anyone could help me ? I just want to display error message which JSON Data contains.

    Thank you very much

    #2
    Error message display is automatic unless you've done something to break it - see RPCManager.addErrorHandler().

    Comment


      #3
      Thanks

      if JSON Data contains error message, it will be display automatically, right?

      so could you please tell me what the method getErrors() of DSResponse will be used to do?

      Comment


        #4
        Actually, I don't care the RPC error, I just want to display the message defined at server side by myself.

        The error message was organized in JSON format and will be sent to SmartGWT client.

        so it's possible to get the error message by using DSResponse.getErrors()?

        Thanks a lot.

        Comment


          #5
          Yes, and we have no reports of a flaw in that method. If you think you've discovered a bug, try producing a standalone test case (see the FAQ).

          Comment


            #6
            Hi Isomorphic,

            My case is the same to this one described as below:

            ------------------------------------------------------------------

            keithc keithc is offline
            Registered Developer

            Join Date: Dec 2008
            Posts: 4
            Default RestDataSource format change
            I have been using RestDataSource in JSON format for several months. Until now it has been necessary to wrap my json data in a response object something like

            {"response": { "status":0, "data":<my json>}}

            I have updated to the latest snapshot and it seems that this is no longer required as my databound components only work if this wrapper is omitted. This is good but I cannot figure out how I should return errors now. I see a getErrors() has been added to DSResponse but what json format is needed to populate it?


            Isomorphic Isomorphic is online now
            Administrator

            Join Date: May 2006
            Posts: 13,358
            Default
            This was a SmartClient core regression, which has been fixed and will hit SVN shortly.

            Comment


              #7
              Fixed many months ago.

              Comment


                #8
                JSON format as below:
                { "response":{ "errors":{"SQL":"SQL Syntax ERROR"}, "data":[] }}

                Is that possible to get the errors by using DSResponse.getErrors() ?

                And is there anything I should pay attention to?

                Comment


                  #9
                  Could populate error message as below:

                  Code:
                  protected void transformResponse(DSResponse response, DSRequest request, Object data) {
                          JSONArray errors = XMLTools.selectObjects(data, "/response/errors");
                          //Handle error message.
                          super.transformResponse(response, request, data);
                  
                  }
                  That's it.

                  Thanks

                  Comment


                    #10
                    I'm having trouble with errors on a RestDataSource aswell.

                    My script returns an XML response like this:

                    <response>
                    <status>-4</status>
                    <errors>
                    <Zend_Auth_Adapter_Exception>
                    A value for the identity was not provided prior to authentication with Zend_Auth_Adapter_DbTable.
                    </Zend_Auth_Adapter_Exception>
                    </errors>
                    </response>

                    now, when i develop, i can access the errors via getErrors() from a DSCallback or HandleErrorHandler. But when i compile the GWT project - there are no more errors! Anyone had this behaviour?

                    cheers, j

                    ----
                    edit:

                    i found the error / reason for misbehaviour:
                    i'm sending http status != 200 and thats a problem for the parser it seems. in development mode, responses are filtered by the http proxy servlet that changes the http response code..
                    however, as i'm now sending any result with http status 200, everything is fine!
                    Last edited by jhohlfeld; 15 Oct 2010, 09:35.

                    Comment

                    Working...
                    X