Session timeout handing in AJAX call
DWR has a textHtmlHandler that allows you to manage what happens when a DWR request receives a response that isn't Javascript. This generally means that a server session has timed out, so it is usual in a textHtmlHandler to redirect to a login screen.
dwr.engine.setTextHtmlHandler(function() {
//automatically take user to logon page due to timeout
document.location.reload();
});
You set a global error handler like this:
dwr.engine.setErrorHandler(handler);
You can also specify call or batch level error or warning handlers. For example, in the call meta-data:
Remote.method(params, {
callback:function(data) { ... },
errorHandler:function(errorString, exception) { ... }
});
or, in batch meta-data:
dwr.engine.beginBatch();
Remote.method(params, function(data) { ... });
// Other remote calls
dwr.engine.endBatch({
errorHandler:function(errorString, exception) { ... }
});
Unfortunately, Dojo doesn't provide such global error handler and has to be handled individually on each onLoad().
load: function(type, data, evt) {
sessionTimeoutCheck(data, evt);
...
}
No comments:
Post a Comment