Announcement

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

    RestDataSource should not call callback when status shows a failure and willHandleError is not true

    What UI interaction you are trying to achieve, from the end user's perspective
    Handle RestDataSource error properly (in the example code below, it should show the "Note" popup instead of the "Warning" popup when the returned status is -1).

    What you expected to happen
    Based on the SmartClient documentation here:
    https://www.smartclient.com/smartcli....errorHandling
    [...] If you specified a callback in your request, it will *not* be called if the status shows a failure [...]
    So when willHandleError is *not* equal to true, I expect that the callback will *not* be called when the returned status is -1.
    Hint: I suspect that adding "return;" just after the call to isc.RPCManager._handleError() inside SmartClient internal method isc.DataSource.fireResponseCallbacks would fix the problem.

    Browser(s) and platform(s) where you see the problem
    Chrome on Red Hat, but expected to happen on all browsers/platforms
    Contents of the SmartClient Developer Console
    "Log messages" area
    Code:
    20:30:13.391:MUP8:INFO:RPCManager:sendQueue[0]: 1 RPCRequest(s); transport: xmlHttpRequest; target: sampleData.json 20:30:13.392:MUP8:DEBUG:RPCManager:XMLHttpRequest GET from sampleData.json with fields: {_operationType: "fetch", _textMatchStyle: "exact", _dataSource: "helloWorldDS", isc_metaDataPrefix: "_", isc_dataFormat: "json"} full URL string: sampleData.json?_operationType=fetch&_textMatchStyle=exact&_dataSource=helloWorldDS&isc_metaDataPrefix=_&isc_dataFormat=json 20:30:13.436:XRP1:INFO:RPCManager:transaction 0 arrived after 43ms 20:30:13.437:XRP1:DEBUG:RPCManager:Result string for transaction 0: "{"response":{"status":-1,"data":{"content":"Hello World"}}} " 20:30:13.438:XRP1:INFO:RPCManager:rpcResponse(unstructured) results -->"{"response":{"status":-1,"data":{"content":"Hello World"}}} "<-- 20:30:13.440:XRP1:DEBUG:xmlBinding:helloWorldDS:Raw response data: {     "response":{         "status":-1,          "data":{             "content":"Hello World"         }     } } 20:30:13.440:XRP1:INFO:xmlBinding:helloWorldDS:JSON recordXPath: '/response/data', selected: Array[1] 20:30:13.441:XRP1:DEBUG:xmlBinding:helloWorldDS:Validated dsResponse.data: [     {         "content":"Hello World"     } ] 20:30:13.441:XRP1:INFO:xmlBinding:helloWorldDS:dsResponse is: {data: Array[1], startRow: 0, status: 0, endRow: 1, totalRows: 1, httpResponseCode: 200, httpResponseText: "{"response":{"status":-1,"data":{"conten..."[60], transactionNum: 0, clientContext: undef, internalClientContext: undef, httpHeaders: Obj}
    Sample code and sample data
    See the simple example below:
    Code:
      
    var handleErrorWasCalled = false;
       isc.rpc.addClassProperties({
        handleError: function (dsResponse) {
          handleErrorWasCalled = true;
          isc.say("handleError was called because<br>dsResponse.status = " + dsResponse.status);
        }
      });
       isc.RestDataSource.create({
        ID:"helloWorldDS",
        dataFormat: "json",
        fields:[
          {name:"content", title:"Content"}
        ],
        fetchDataURL:"sampleData.json",
      });
       isc.IButton.create({
        border: "2px solid grey",
        height: "25px",
        title:"Fetch Content",
        click: function () {
          helloWorldDS.fetchData(
            null,
            function (dsResponse){
              if (handleErrorWasCalled && dsResponse.willHandleError !== true) {
                isc.warn("RestDataSource callback was called even though dsResponse.status = " + dsResponse.status + "<br>and dsResponse.willHandleError = " + dsResponse.willHandleError);
              } else {
                isc.say("RestDataSource content = " + dsResponse.data[0].content);
              }
            }
          );
        }
      });
    Sample data 1:
    File sampleData.json contains the following:
    Code:
    {"response":{"status":0,"data":{"content":"Hello World"}}}
    Expected behavior:
    When clicking on the "Fetch Content" button, a "Note" popup shows the following: "RestDataSource content = Hello World" This is working as expected
    Sample data 2:
    File sampleData.json contains the following:
    Code:
    {"response":{"status":-1,"data":{"content":"Hello World"}}}
    Expected behavior:
    When clicking on the "Fetch Content" button, a "Note" popup shows the following: "handleError was called because dsResponse.status = -1"
    Bug: instead, the "Note" popup is overridden by the "Warning" popup showing the following: "RestDataSource callback was called even though dsResponse.status = -1 and dsResponse.willHandleError = undefined"

    SmartClient version: v9.1p_2017-05-26/Pro Development Only (built 2017-05-26)

    #2
    Like the other issue you reported, this one is fixed in newer releases such as SC 11.1p. Unfortunately, porting back our changes in this area of code would be more difficult, so we'd rather not do it.

    Doing new development against SC 9.1p really doesn't make sense. You'll need to upgrade (to SC 11.1p ideally, but at least SC 10.1p) to pick up this fix.

    Comment

    Working...
    X