Package er.ajax.example2

Source Code of er.ajax.example2.Application

package er.ajax.example2;

import com.webobjects.appserver.WOContext;
import com.webobjects.appserver.WOResponse;

import er.ajax.AjaxResponse;
import er.ajax.AjaxUtils;
import er.ajax.example2.util.StringUtils;
import er.extensions.appserver.ERXApplication;

public class Application extends ERXApplication {
  public static void main(String[] argv) {
    ERXApplication.main(argv, Application.class);
  }

  public Application() {
    AjaxResponse.addAjaxResponseAppender(new NotificationResponseAppender());
  }

  @Override
  public WOResponse handleException(Exception exception, WOContext context) {
    WOResponse response;
    if (context != null && AjaxUtils.isAjaxRequest(context.request())) {
      response = createResponseInContext(context);
      response.appendContentString(StringUtils.toErrorString(exception));
    }
    else {
      response = super.handleException(exception, context);
    }
    return response;
  }

  @Override
  public WOResponse handleSessionRestorationErrorInContext(WOContext context) {
    WOResponse response;
    if (context != null && AjaxUtils.isAjaxRequest(context.request())) {
      response = createResponseInContext(context);
      String sessionExpiredUrl = context.directActionURLForActionNamed("sessionExpired", null);
      response.appendContentString("<script>document.location.href='" + sessionExpiredUrl + "';</script>");
    }
    else {
      response = super.handleSessionRestorationErrorInContext(context);
    }
    return response;
  }
}
TOP

Related Classes of er.ajax.example2.Application

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.