Monday, August 12, 2013

DWR error handling

Exception/error handling of DWR calls can be centralized by setting the handlers. More here: http://directwebremoting.org/dwr/documentation/browser/errors.html


dwr.engine.setErrorHandler(UI.errorHandler);
dwr.engine.setTextHtmlHandler(UI.textHtmlHandler);

 // Handler for errors and exceptions
 errorHandler : function(msg, param2) {
  UI.hideLoading();
  Utils.resetClick();
  View.error(msg, 700)
 },

 // Handler when Ajax returns a text such as session timeout, page not found etc...
 textHtmlHandler : function() {
  UI.hideLoading();
  //View.error("Your session has expired, please login again." );
   document.location = '/adapt/web/jsp/timeout.jsp';
 },

No comments:

Post a Comment