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
Sample code and sample data
See the simple example below:
Sample data 1:
File sampleData.json contains the following:
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:
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)
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}
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); } } ); } });
File sampleData.json contains the following:
Code:
{"response":{"status":0,"data":{"content":"Hello World"}}}
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"}}}
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)
Comment