Package org.zkoss.zk.ui

Examples of org.zkoss.zk.ui.WebApp


    final HttpSession hsess = request.getSession(create);
    return hsess != null ? getSession(ctx, hsess, request): null;
  }
  private static final Session getSession(ServletContext ctx,
  HttpSession hsess, HttpServletRequest request) {
    final WebApp wapp = getWebManager(ctx).getWebApp();
    final Session sess = SessionsCtrl.getSession(wapp, hsess);
    return sess != null ? sess:
      SessionsCtrl.newSession(wapp, hsess, request);
  }
View Full Code Here


  /*package*/ static final
  void sessionDestroyed(HttpSession hsess) {
    //Under JBoss, the servlet might be destroyed before this callback
    final WebManager webman = getWebManagerIfAny(hsess.getServletContext());
    if (webman != null) {
      final WebApp wapp = webman.getWebApp();
      final Session sess = (Session)SessionsCtrl.getSession(wapp, hsess);
      if (sess != null)
        ((WebAppCtrl)wapp).sessionDestroyed(sess);
    }
  }
View Full Code Here

  private static final String ATTR_CACHE = "javax.zkoss.zk.desktop-cache";
    private static final long serialVersionUID = 20060622L;

  //-- DesktopCacheProvider --//
  public DesktopCache getDesktopCache(Session sess) {
    final WebApp wapp = sess.getWebApp();
    DesktopCache dc = (DesktopCache)wapp.getAttribute(ATTR_CACHE);
    if (dc == null) {
      synchronized (this) {
        dc = (DesktopCache)wapp.getAttribute(ATTR_CACHE);
        if (dc == null) {
          dc = new SimpleDesktopCache(
            sess.getWebApp().getConfiguration());
          wapp.setAttribute(ATTR_CACHE, dc);
        }
      }
    }
    return dc;
  }
View Full Code Here

    final String uuid = l >= 0 ? pi.substring(k, l): pi.substring(k);

    Media media;
    boolean download = false;
    try {
      final WebApp wapp = sess.getWebApp();
      final WebAppCtrl wappc = (WebAppCtrl)wapp;
      final UiEngine uieng = wappc.getUiEngine();
      final Desktop desktop = wappc.getDesktopCache(sess).getDesktop(dtid);
      final DesktopCtrl desktopCtrl = (DesktopCtrl)desktop;

      final Execution oldexec = Executions.getCurrent();
      final Execution exec = new ExecutionImpl(
        _ctx, request, response, desktop, null);
      uieng.activate(exec);

      final Configuration config = wapp.getConfiguration();
      boolean err = false;
      try {
        config.invokeExecutionInits(exec, oldexec);
        desktopCtrl.invokeExecutionInits(exec, oldexec);
View Full Code Here

    _compress = param == null || param.length() == 0 || "true".equals(param);
    if (!_compress)
      webman.getClassWebResource().setCompress(null); //disable all

    //Copies au extensions defined before DHtmlUpdateServlet is started
    final WebApp wapp = webman.getWebApp();
    final Map aues = (Map)wapp.getAttribute(ATTR_AU_PROCESSORS);
    if (aues != null) {
      for (Iterator it = aues.entrySet().iterator(); it.hasNext();) {
        final Map.Entry me = (Map.Entry)it.next();
        addAuExtension((String)me.getKey(), (AuExtension)me.getValue());
      }
      wapp.removeAttribute(ATTR_AU_PROCESSORS);
    }

    //ZK 5: extension defined in init-param has the higher priority
    for (int j = 0;;) {
      param = config.getInitParameter("extension" + j++);
View Full Code Here

        oldsess = SessionsCtrl.getRawCurrent();
        SessionsCtrl.setCurrent(new SessionResolverImpl(_ctx, request));
        //it might be created later
      }

      WebApp wapp;
      Session sess;
      final Object old = hsess != null?
        (wapp = WebManager.getWebAppIfAny(_ctx)) != null &&
        (sess = SessionsCtrl.getSession(wapp, hsess)) != null ?
          I18Ns.setup(sess, request, response, "UTF-8"):
          I18Ns.setup(hsess, request, response, "UTF-8"):
        Charsets.setup(null, request, response, "UTF-8");
      try {
        cwr.service(request, response,
            pi.substring(ClassWebResource.PATH_PREFIX.length()));
      } finally {
        if (hsess != null) I18Ns.cleanup(request, old);
        else {
          Charsets.cleanup(request, old);
          SessionsCtrl.setRawCurrent(oldsess);
        }
      }
      return; //done
    }

    final Session sess = WebManager.getSession(_ctx, request, false);
    if (withpi) {
      final AuExtension aue = getAuExtensionByPath(pi);
      if (aue == null) {
        response.sendError(response.SC_NOT_FOUND);
        log.debug("Unknown path info: "+pi);
        return;
      }

      Object oldsess = null;
      if (sess == null) {
        oldsess = SessionsCtrl.getRawCurrent();
        SessionsCtrl.setCurrent(new SessionResolverImpl(_ctx, request));
        //it might be created later
      }

      final Object old = sess != null?
        I18Ns.setup(sess, request, response, "UTF-8"):
        Charsets.setup(null, request, response, "UTF-8");
      try {
        aue.service(request, response, pi);
      } finally {
        if (sess != null) I18Ns.cleanup(request, old);
        else {
          Charsets.cleanup(request, old);
          SessionsCtrl.setRawCurrent(oldsess);
        }
      }
      return; //done
    }

    //AU
    if (sess == null) {
      response.setIntHeader("ZK-Error", response.SC_GONE); //denote timeout

      //Bug 1849088: rmDesktop might be sent after invalidate
      //Bug 1859776: need send response to client for redirect or others
      final WebApp wapp = WebManager.getWebAppIfAny(_ctx);
      final String dtid = getAuDecoder(wapp).getDesktopId(request);
      if (dtid != null)
        sessionTimeout(request, response, wapp, dtid);
      return;
    }
View Full Code Here

    final String errClient = request.getHeader("ZK-Error-Report");
    if (errClient != null)
      if (log.debugable()) log.debug("Error found at client: "+errClient+"\n"+Servlets.getDetail(request));

    //parse desktop ID
    final WebApp wapp = sess.getWebApp();
    final WebAppCtrl wappc = (WebAppCtrl)wapp;
    final AuDecoder audec = getAuDecoder(wapp);
    final String dtid = audec.getDesktopId(request);
    if (dtid == null) {
      //Bug 1929139: incomplete request (IE only)
      if (log.debugable()) {
        final String msg = "Incomplete request\n"+Servlets.getDetail(request);
        log.debug(msg);
      }

      response.sendError(467, "Incomplete request");
      return;
    }

    Desktop desktop = getDesktop(sess, dtid);
    if (desktop == null) {
      final String cmdId = audec.getFirstCommand(request);
      if (!"rmDesktop".equals(cmdId))
        desktop = recoverDesktop(sess, request, response, wappc, dtid);

      if (desktop == null) {
        response.setIntHeader("ZK-Error", response.SC_GONE); //denote timeout
        sessionTimeout(request, response, wapp, dtid);
        return;
      }
    }
    WebManager.setDesktop(request, desktop);
      //reason: a new page might be created (such as include)

    final String sid = request.getHeader("ZK-SID");
    if (sid != null) //Some client might not have ZK-SID
      response.setHeader("ZK-SID", sid);

    //parse commands
    final Configuration config = wapp.getConfiguration();
    final List aureqs;
    boolean keepAlive = false;
    try {
      final boolean timerKeepAlive = config.isTimerKeepAlive();
      aureqs = audec.decode(request, desktop);
View Full Code Here

  private static final String APP_SCOPE = "ZK_SPRING_APP_SCOPE";
 
  public Object get(String name, ObjectFactory objectFactory) {
    final Execution exec = Executions.getCurrent();
    if (exec != null) {
      final WebApp app = exec.getDesktop().getWebApp();
      Map appScope = (Map) app.getAttribute(APP_SCOPE);
      if (appScope == null) {
        app.setAttribute(APP_SCOPE, appScope = new HashMap());
      }
      Object scopedObject = appScope.get(name);
      if (scopedObject == null) {
        scopedObject = objectFactory.getObject();
        appScope.put(name, scopedObject);
View Full Code Here

  }

  public String getConversationId() {
    final Execution exec = Executions.getCurrent();
    if (exec != null) {
      final WebApp app = exec.getDesktop().getWebApp();
      if (app != null) {
        return app.getAppName();
      }
    }
    return null;
  }
View Full Code Here

  }

  public Object remove(String name) {
    final Execution exec = Executions.getCurrent();
    if (exec != null) {
      final WebApp app = exec.getDesktop().getWebApp();
      final Map appScope = (Map) app.getAttribute(APP_SCOPE);
      return (appScope != null) ? appScope.remove(name) : null;
    }
    throw new IllegalStateException("Unable to get application scope bean: "+name+". Do you access it in ZK event listener?");
  }
View Full Code Here

TOP

Related Classes of org.zkoss.zk.ui.WebApp

Copyright © 2018 www.massapicom. 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.