The next line in the docs after the one you quoted answers your question: forms and other components such as editable grids expect validation errors as normal, recoverable errors and handle them, so you don't normally have to do anything about this kind of error. The mechanism is just that such components set willHandleError:true on the requests they send, and only forward unrecoverable errors to central error handling.
However, if you directly submit a request that may result in validation errors, you'll need to handle that error (either via willHandleError and the normal callback, or via central handling) or the user is going to get a pop-up error message.
Announcement
Collapse
No announcement yet.
X
-
HandleErrorCallback for validation failed status
Hi Isomorphic,
We have set errorHandler for RPCManager in our main EntryPoint of appication:
Like this:
and we assume according to documentation that for all requests where with setWillHandleError(false) and negative response status this callback will be called.Code:@Override public void onModuleLoad() { RPCManager.setHandleErrorCallback(new HandleErrorCallback() { @Override public void handleError(DSResponse response, DSRequest request) { SC.warn("Error"); } } }
But could you please clarify situation when status is Validation Error?(-4). Should this callback also called for response with status -4?
I am asking because in java doc (http://www.smartclient.com/smartgwte...rHandling.html) it is written "Validation errors are treated differently from other errors, precisely because they are an expected part of the normal operation of the system"
and also "The remainder of this article concerns unrecoverable errors. These are errors with the system itself, for example:
A network transport problem
A server-side crash
An update failed because a transaction was rolled back
Errors like this can either be handled centrally, or you can choose to handle them in your regular callback code. DSRequest calls default to centralized handling; RPCRequest calls default to user error handling in the callback"
We have a case when we send dsRequest via queue where dmi method is called inside and from this dmi method we receive dsResponse with status -4:
This is the similar code which we have and as a result we see that HandleErrorCallback is called also:
and inside DMI we haveCode:final boolean wasQueuing = RPCManager.startQueue(); DSRequest dsRequest = new DSRequest(DSOperationType.ADD, new Record()); dsRequest.setWillHandleError(false); dsRequest.setOperationId("addCustom"); dataSource.execute(dsRequest); DSRequest dsRequest2 = new DSRequest(DSOperationType.ADD, new Record()); dsRequest2.setWillHandleError(false); dsRequest2.setOperationId("addCustom"); dataSource.execute(dsRequest2); final RPCQueueCallback validateCallback = new RPCQueueCallback() { @Override public void execute(RPCResponse... rpcResponses) { SC.warn("Validation Error"); } }; if (!wasQueuing) { RPCManager.sendQueue(validateCallback); } } });
We use SmartClient Version: v10.0p_2017-01-18/PowerEdition Deployment (built 2017-01-18).Code:public DSResponse addCustom(DSRequest dsRequest) throws Exception { log.info("procesing DMI ADD operation"); DSResponse dsResponse = new DSResponse(); dsResponse.setStatus(DSResponse.STATUS_VALIDATION_ERROR); return dsResponse; }
Browser version FF 26.
Last edited by ksenia_korenkova; 7 Jun 2017, 00:56.Tags: None
Leave a comment: