We are using SmartGWT 2.5 and I am using DynamicForm.saveData(new DSCallback()) method to submit the form to a data source. When the data is processed without failures, the execute() method is called which is all great. My problem is that DSCallback interface does not mention any other methods I’d need to implement to handle failures.
Any suggestions or hints are very appreciated.
Thanks,
Henry
Failures such as validation errors are handled automatically by the form. Unrecoverable errors go to central error handling on RPCManager (addErrorHandler). If you want the callback on saveData() to fire for both of these, set rpcRequest.willHandleError:true on the dsRequestProperties.
Thank you for a quick reply. I am not sure how to change the dsRequestProperties. I am not actually referencing DSRequest anywhere in my code. Here is my code:
//when button click event is fired
form.saveData(new DSCallback() {
@Override
public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
Record[] records = dsResponse.getData();
// process the response contained in records
}
}
Not sure where I need to reference and modify the rpcRequest.
What about form.addFormSubmitFailedHandler()? would that be useful in this case?
Thank you again! It worked great. If anyone else stumbles on this, the answer is rather simple:
DSRequest dsRequest = new DSRequest();
dsRequest.setWillHandleError(true);
form.saveData(new DSCallback() {
@Override
public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
if(dsResponse.getStatus() != DSResponse.STATUS_SUCCESS){
//handle error
}
Record[] records = dsResponse.getData();
// process the response contained in records
}
}, dsRequest);