Package org.zkoss.zk.ui

Examples of org.zkoss.zk.ui.Execution


    try {
      if (desktop != null) { //recycle
        final Page page = Utils.getMainPage(desktop);
        if (page != null) {
          final Execution exec = new ExecutionImpl(
            _ctx, request, response, desktop, page);
          _webman.setDesktop(request, desktop);
          wappc.getUiEngine().recycleDesktop(exec, page, out);
        } else
          desktop = null; //something wrong (not possible; just in case)
      }
      if (desktop == null) {
        desktop = _webman.getDesktop(sess, request, response, path, true);
        if (desktop == null) //forward or redirect
          return true;

        final RequestInfo ri = new RequestInfoImpl(
          wapp, sess, desktop, request,
          PageDefinitions.getLocator(wapp, path));
        sess.setAttribute(Attributes.GAE_FIX, new Integer(0));
        ((SessionCtrl)sess).notifyClientRequest(true);

        final UiFactory uf = wappc.getUiFactory();
        if (uf.isRichlet(ri, bRichlet)) {
          final Richlet richlet = uf.getRichlet(ri, path);
          if (richlet == null)
            return false; //not found

          final Page page = WebManager.newPage(uf, ri, richlet, response, path);
          final Execution exec = new ExecutionImpl(
            _ctx, request, response, desktop, page);
          wappc.getUiEngine().execNewPage(exec, richlet, page, out);
            //no need to set device type here, since UiEngine will do it later
        } else {
          final PageDefinition pagedef = uf.getPageDefinition(ri, path);
          if (pagedef == null)
            return false; //not found

          final Page page = WebManager.newPage(uf, ri, pagedef, response, path);
          final Execution exec = new ExecutionImpl(
            _ctx, request, response, desktop, page);
          wappc.getUiEngine().execNewPage(exec, pagedef, page, out);
        }
      }
View Full Code Here


      final UiFactory uf = wappc.getUiFactory();
      final PageDefinition pagedef =
        uf.getPageDefinitionDirectly(ri, content, _ext);

      final Page page = WebManager.newPage(uf, ri, pagedef, response, path);
      final Execution exec =
        new ExecutionImpl(_ctx, request, response, desktop, page);
      final StringWriter out = new StringWriter(4096*2);
      wappc.getUiEngine().execNewPage(exec, pagedef, page, out);

      //bug 1738368: Jetty refuses wrong content length
View Full Code Here

  public void setTitle(String title) {
    if (title == null) title = "";
    if (!_title.equals(title)) {
      _title = title;
      if (_desktop != null) {
        final Execution exec = getExecution();
        if (_title.length() > 0) {
          _title = (String)exec.evaluate(this, _title, String.class);
          if (_title == null) _title = "";
        }

        if (exec.isAsyncUpdate(this))
          getUiEngine().addResponse(new AuSetTitle(_title));
      }
    }
  }
View Full Code Here

  public void setStyle(String style) {
    if (style == null) style = "";
    if (!_style.equals(style)) {
      _style = style;
      if (_desktop != null) {
        final Execution exec = getExecution();
        if (_style.length() > 0) {
          _style = (String)exec.evaluate(this, _style, String.class);
          if (_style == null) _style = "";
        }
        //FUTURE: might support the change of style dynamically
      }
    }
View Full Code Here

      return _desktop != null ?
        _desktop.getWebApp().getAttributes(): Collections.EMPTY_MAP;
    case PAGE_SCOPE:
      return _attrs.getAttributes();
    case REQUEST_SCOPE:
      final Execution exec = getExecution();
      if (exec != null) return exec.getAttributes();
      //fall thru
    default:
      return Collections.EMPTY_MAP;
    }
  }
View Full Code Here

    return getXelVariable(null, null, name, false);
  }
  public Object getXelVariable(
  XelContext ctx, Object base, Object name, boolean ignoreExec) {
    if (!ignoreExec) {
      final Execution exec = getExecution();
      if (exec != null)
        return Evaluators.resolveVariable(
          ctx, exec.getVariableResolver(), base, name);
          //note: ExecutionResolver will call back this method
    }
   
    if (_resolvers != null) {
      for (Iterator it = _resolvers.iterator(); it.hasNext();) {
View Full Code Here

  //-- PageCtrl --//
  public void preInit() {
    if (_desktop != null)
      throw new IllegalStateException("init twice");

    final Execution exec = Executions.getCurrent();
    _desktop = exec.getDesktop();
    if (_desktop == null)
      throw new IllegalArgumentException("null desktop");

    _desktop.getWebApp().getConfiguration().init(this);
  }
View Full Code Here

      throw new IllegalArgumentException("null desktop");

    _desktop.getWebApp().getConfiguration().init(this);
  }
  public void init(PageConfig config) {
    final Execution exec = Executions.getCurrent();

    if (((ExecutionCtrl)exec).isRecovering()) {
      final String uuid = config.getUuid(), id = config.getId();
      if (uuid == null || id == null)
        throw new IllegalArgumentException("both id and uuid are required in recovering");
      _uuid = uuid;
      _id = id;
    } else {
      _uuid = ((DesktopCtrl)_desktop).getNextUuid(this);

      if (_id == null || _id.length() == 0)
        _id = config.getId();
      if (_id != null)
        _id = (String)exec.evaluate(this, _id, String.class);
      if (_id == null) {
        _id = "";
      } else if (_id.length() != 0) {
        final String INVALID = ".&\\%";
        if (Strings.anyOf(_id, INVALID, 0) < _id.length())
View Full Code Here

  }

  public void redraw(Writer out)
  throws IOException {
    String ctl;
    final Execution exec = getExecution();
    final boolean au = exec.isAsyncUpdate(null);
    if (!au && !exec.isIncluded()
    && ((ctl=ExecutionsCtrl.getPageRedrawControl(exec)) == null
      || "desktop".equals(ctl))) {
      if (!au && shallIE7Compatible())
        try {
          if (exec.isBrowser("ie8")
          && !exec.containsResponseHeader("X-UA-Compatible"))
            exec.setResponseHeader("X-UA-Compatible", "IE=EmulateIE7");
        } catch (Throwable ex) { //ignore (it might not be allowed)
        }

//FUTURE: Consider if config.isKeepDesktopAcrossVisits() implies cacheable
//Why yes: the client doesn't need to ask the server for updated content
//Why no: browsers seems fail to handle DHTML correctly (when BACK to
//a DHTML page), so it is better to let the server handle cache, if any
      final boolean cacheable =
        _cacheable != null ?  _cacheable.booleanValue():
          _desktop.getDevice().isCacheable();
      if (!cacheable) {
        //Bug 1520444
        exec.setResponseHeader("Pragma", "no-cache");
        exec.addResponseHeader("Cache-Control", "no-cache");
        exec.addResponseHeader("Cache-Control", "no-store");
        //exec.addResponseHeader("Cache-Control", "private");
        //exec.addResponseHeader("Cache-Control", "max-age=0");
        //exec.addResponseHeader("Cache-Control", "s-maxage=0");
        //exec.addResponseHeader("Cache-Control", "must-revalidate");
        //exec.addResponseHeader("Cache-Control", "proxy-revalidate");
        //exec.addResponseHeader("Cache-Control", "post-check=0");
        //exec.addResponseHeader("Cache-Control", "pre-check=0");
        exec.setResponseHeader("Expires", "-1");

        exec.setAttribute(Attributes.NO_CACHE, Boolean.TRUE);
        //so HtmlPageRenderers.outLangJavaScripts generates JS's keepDesktop correctly
      }
      if (_hdres != null)
        for (Iterator it = _hdres.iterator(); it.hasNext();) {
          final Object[] vals = (Object[])it.next();
          final String nm = (String)vals[0];
          final Object val = vals[1];
          final boolean add = ((Boolean)vals[2]).booleanValue();
          if (val instanceof Date) {
            if (add) exec.addResponseHeader(nm, (Date)val);
            else exec.setResponseHeader(nm, (Date)val);
          } else {
            if (add) exec.addResponseHeader(nm, (String)val);
            else exec.setResponseHeader(nm, (String)val);
          }
        }
    }

    final PageRenderer renderer = (PageRenderer)
      exec.getAttribute(Attributes.PAGE_RENDERER);
    final Object oldrendering =
      exec.setAttribute(Attributes.PAGE_RENDERING, Boolean.TRUE);
    try {
      (renderer != null ? renderer: _langdef.getPageRenderer())
        .render(this, out);
    } finally {
      if (oldrendering != null)
        exec.setAttribute(Attributes.PAGE_RENDERING, oldrendering);
      else
        exec.removeAttribute(Attributes.PAGE_RENDERING);
    }
  }
View Full Code Here

  }
  public AuResponse getResponse() {
    return null;
  }
  public void finish() {
    final Execution exec = Executions.getCurrent();

    //Bug 1753712: disable visualizer since responses were gen.
    ((ExecutionCtrl)exec).getVisualizer().disable();

    //Bug 1868371: we shall postpone the cleanup to the last step
    final Desktop dt = exec.getDesktop();
    final WebApp wapp = dt.getWebApp();
    final DesktopRecycle dtrc = wapp.getConfiguration().getDesktopRecycle();
    if (dtrc == null || !beforeRemove(dtrc, exec, dt))
      ((WebAppCtrl)wapp).getDesktopCache(dt.getSession()).removeDesktop(dt);
  }
View Full Code Here

TOP

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

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.