We are using SmartGWT Power Edition 3.0 to write web application and we want to have some exception handling on client side if server have exception. And we will have the code as following. And client side we plan to have error handler method (will call when STATUS_FAILURE is set) and I want to get back the Record that I set in server side in client side handler. But I can get one record but cannot found any attribute in the record, is there any missing...? or wrongly code?
Following is the code segment for your reference
Server Side
ClientSide
Result
Following is the code segment for your reference
Server Side
Code:
dsResponse = new DSResponse(); dsResponse.setStatus(DSResponse.STATUS_FAILURE); Map params = new HashMap(); params.put("errorCode", "10001"); params.put("errorMsg", "The user have no authorization to read the data"); dsResponse.setData(params);
Code:
RPCManager.setHandleErrorCallback(new HandleErrorCallback(){ @Override public void handleError(DSResponse response, DSRequest request) { if (response.getStatus()<0) { SC.say("Error Code --> " + Integer.toString(response.getStatus())); com.allen_sauer.gwt.log.client.Log.error("#OfRecord:"+ Integer.toString(response.getData().length)); if ( response.getData().length > 0 ) { Record r = response.getData()[0]; String [] ss = r.getAttributes(); for ( int i=0;i<ss.length;i++ ) { com.allen_sauer.gwt.log.client.Log.error("Attribute:" + ss[i] + " --- value " + r.getAttributeAsString(ss[i])); } } } } });
Code:
#OfRecord = 1
Comment