Remember when we used to call DWR the remote method is written like this
Remote.method (params,function (data) {
//server-Side Execution-client logic, such as
alert ("Returned after server execution:" +data);
});
Remote.method (params,function (data) {
//server-Side Execution-client logic, such as
alert ("Returned after server execution:" +data);
});
The first to the penultimate parameter is the data that the client passes to the server, and the last parameter is directly a callback function. Because the JS code generated by the server based on the Java object is:
Remote.method = function (P0, callback) {
Dwr.engine._execute (remote._path, ' Remote ', ' method ', P0, callback);
}
So it's intuitive to interpret the second argument as a callback function. Of course, note that the remote method mentioned above is a parameter, and if it is multiple parameters, callback is always the last parameter, such as:
remote.method= function (P0, p1, callback) {
Dwr.engine._execute (remote._path, ' Remote ', ' method ', P0, p1, callback );
}
Your DWR program If all goes well, that's all right, count you lucky; If you encounter a remote method that throws an exception while processing your request, you will see that DWR will only give you an alert ("Error") that is simply wrong, and that is not enough. So you need to figure out how to proactively capture this bug and show it to the user in a more friendly way. So if you encounter a remote call to the exception, you are also lucky, because you can think to learn one.
The alert ("error") is actually a DWR global error handling that can be changed by Dwr.engine.setErrorHandler (ErrorHandler) to its default behavior, such as
function Errh (errorstring, exception) {
alert ("Prompts you for a custom global error message.) ");
}
Dwr.engine.setErrorHandler (ERRH);