SmartGWT 3.0p (2012-08-30)
I'm calling fetchData from a datasource (RestDataSource) and a callback is defined.
WillHandleError is set to false on the request.
If the server returns XML with status set to -1, then the error message is displayed correctly... but the callback is called, which is not what we want.
If I call fetchData from a listgrid connected to the same datasource, the error message is displayed correctly and the callback is not executed, like it is supposed to do.
Here is the code of the datasource...
Can someone help me find why this is not working correctly ?
It should be easy to reproduce.
I declare a datasource that extends the BaseDataSource.
Then I just call it, and even if status of the response is -1, the callback is executed.
Here is the XML returned by the server.
<response><status>-1</status><data>You are not authorized to use this module</data></response>
Waiting for help...
I'm calling fetchData from a datasource (RestDataSource) and a callback is defined.
WillHandleError is set to false on the request.
If the server returns XML with status set to -1, then the error message is displayed correctly... but the callback is called, which is not what we want.
If I call fetchData from a listgrid connected to the same datasource, the error message is displayed correctly and the callback is not executed, like it is supposed to do.
Here is the code of the datasource...
Code:
public class BaseDataSource extends RestDataSource { protected BaseDataSource(String id) { setID(id); setDataProtocol(DSProtocol.POSTMESSAGE); setDataURL("/RESTServlet/appserver"); OperationBinding fetch = new OperationBinding(); fetch.setOperationType(DSOperationType.FETCH); fetch.setDataProtocol(DSProtocol.POSTMESSAGE); OperationBinding add = new OperationBinding(); add.setOperationType(DSOperationType.ADD); add.setDataProtocol(DSProtocol.POSTMESSAGE); OperationBinding update = new OperationBinding(); update.setOperationType(DSOperationType.UPDATE); update.setDataProtocol(DSProtocol.POSTMESSAGE); OperationBinding remove = new OperationBinding(); remove.setOperationType(DSOperationType.REMOVE); remove.setDataProtocol(DSProtocol.POSTMESSAGE); setOperationBindings(fetch, add, update, remove); } private void setParams() { String sessionId = Session.getInstance().getSessionId(); String userName = sessionId.equals("") ? Session.getInstance().getUserName() : ""; String password = sessionId.equals("") ? Session.getInstance().getPassword() : ""; String appServer = Session.getInstance().getAppServer(); String env = Session.getInstance().userInfo.getEnvironment(); String session = userName + ":" + password + ":" + sessionId + ":" + appServer + ":" + env; String encSession = Base64.encode(session); final HashMap<String,String> map = new HashMap<String,String>(); map.put("session", encSession); setDefaultParams(map); } @Override public Object transformRequest(DSRequest request) { request.setWillHandleError(false); Object objRequest = super.transformRequest(request); setParams(); return objRequest; } }
It should be easy to reproduce.
I declare a datasource that extends the BaseDataSource.
Code:
public class TestDataSource extends BaseDataSource { private static TestDataSource instance = new TestDataSource("test"); public static TestDataSource getInstance() { return instance; } private TestDataSource(String id) { super(id); setDataURL("/RESTServlet/getTest"); DataSourceTextField field1 = new DataSourceTextField("field1", "field1"); field1.setCanSave(true); field1.setCanEdit(true); addField(field1); }; }
Code:
TestDataSource.getInstance().fetchData(crit, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { SC.warn(Integer.toString(response.getStatus())); } });
Here is the XML returned by the server.
<response><status>-1</status><data>You are not authorized to use this module</data></response>
Waiting for help...
Comment