Package org.zkoss.zk.ui

Examples of org.zkoss.zk.ui.Execution


  public static Component getComponentById(Component comp, String id) {
    final int len = id.length();
    if (id.startsWith("uuid(") && id.charAt(len - 1) == ')') {
      Desktop dt = comp.getDesktop();
      if (dt == null) {
        final Execution exec = Executions.getCurrent();
        if (exec == null)
          return null;
        dt = exec.getDesktop();
      }
      return dt != null ? dt.getComponentByUuidIfAny(id.substring(5, len - 1)): null;
    }
    return comp.getFellowIfAny(id);
  }
View Full Code Here


  //AfterCompose//
  public void afterCompose() {
    _afterComposed = true;
    fixModeOnly();
    if (_instantMode) {
      final Execution exec = getExecution();
      final Map old = setupDynams(exec);
      try {
        final int j = _src.indexOf('?');
        exec.createComponents(j >= 0 ? _src.substring(0, j): _src, this, null);
          //TODO: convert query string to arg
      } finally {
        restoreDynams(exec, old);
      }
    }
View Full Code Here

      ueng.setOwner(old);
    }
  }
  private void include(Writer out) throws IOException {
    final Desktop desktop = getDesktop();
    final Execution exec = getExecution();
    final String src = exec.toAbsoluteURI(_src, false);
    final Map old = setupDynams(exec);
    ComponentRedraws.beforeRedraw(true); //starting a new page
    try {
      exec.include(out, src, null, 0);
    } catch (Throwable err) {
      setChildPage(null);
    //though DHtmlLayoutServlet handles exception, we still have to
    //handle it because src might not be ZUML
      final String errpg =
        desktop.getWebApp().getConfiguration().getErrorPage(
          desktop.getDeviceType(), err);
      if (errpg != null) {
        try {
          exec.setAttribute("javax.servlet.error.message", Exceptions.getMessage(err));
          exec.setAttribute("javax.servlet.error.exception", err);
          exec.setAttribute("javax.servlet.error.exception_type", err.getClass());
          exec.setAttribute("javax.servlet.error.status_code", new Integer(500));
          exec.include(out, errpg, null, 0);
          return; //done
        } catch (IOException ex) { //eat it (connection off)
        } catch (Throwable ex) {
          log.warning("Failed to load the error page: "+errpg, ex);
        }
      }

      final String msg = Messages.get(MZk.PAGE_FAILED,
        new Object[] {src, Exceptions.getMessage(err),
          Exceptions.formatStackTrace(null, err, null, 6)});
      final HashMap attrs = new HashMap();
      attrs.put(Attributes.ALERT_TYPE, "error");
      attrs.put(Attributes.ALERT, msg);
      exec.include(out,
        "~./html/alert.dsp", attrs, Execution.PASS_THRU_ATTR);
    } finally {
      ComponentRedraws.afterRedraw();
      restoreDynams(exec, old);
    }
View Full Code Here

   */
  public static
  Media[] get(String message, String title, int max, int maxsize, boolean alwaysNative)
  throws InterruptedException {
    final Map params = new HashMap(8);
    final Execution exec = Executions.getCurrent();
    params.put("message", message == null ?
      Messages.get(MZul.UPLOAD_MESSAGE): message);
    params.put("title", title == null ?
      Messages.get(MZul.UPLOAD_TITLE): title);
    params.put("max", new Integer(max == 0 ? 1 : max > 1000 ? 1000: max < -1000 ? -1000 : max));
    params.put("native", Boolean.valueOf(alwaysNative));
    params.put("maxsize", String.valueOf(maxsize));
   
    final FileuploadDlg dlg = (FileuploadDlg)
      exec.createComponents(
        _templ, null, params);
    try {
      dlg.doModal();
    } catch (Throwable ex) {
      dlg.detach();
View Full Code Here

    // do nothing
  }

  public void doInit(Page page, Map args) throws Exception {
    //first called doInit, last called doAfterCompose
    final Execution exec = Executions.getCurrent();
    if (exec.getAttribute(RESOLVE_COMPOSITION) == null) {
      exec.setAttribute(RESOLVE_COMPOSITION, this);
    }
    final Component parent = (Component) exec.getAttribute(PARENT);
    for (Iterator it = args.values().iterator(); it.hasNext();)
      exec.createComponents((String)it.next(), parent, null);
  }
View Full Code Here

    for (Iterator it = args.values().iterator(); it.hasNext();)
      exec.createComponents((String)it.next(), parent, null);
  }

  public void doAfterCompose(Page page, Component[] comps) throws Exception {
    final Execution exec = Executions.getCurrent();

    //resolve only once in the last page
    if (exec.getAttribute(RESOLVE_COMPOSITION) != this) {
      return;
    }
    exec.removeAttribute(RESOLVE_COMPOSITION);
   
    // resolve insert components
    final Map insertMap = new HashMap(); //(insert name, insert component)
    final Component parent = (Component) exec.getAttribute(PARENT);
    final Collection roots = parent == null ? page.getRoots() : parent.getChildren();
    resolveInsertComponents(roots, insertMap);

    if (!roots.isEmpty()) {
      Component comp = (Component) roots.iterator().next();
View Full Code Here

        _model = model;
        initDataListener();
      }

      final Execution exec = Executions.getCurrent();
      final boolean defer = exec == null ? false : exec.getAttribute("zkoss.Grid.deferInitModel_"+getUuid()) != null;
      final boolean rod = evalRod();
      //Always syncModel because it is easier for user to enfore reload
      if (!defer || !rod) { //if attached and rod, defer the model sync
        getDataLoader().syncModel(-1, -1); //create rows if necessary
      } else if (inPagingMold()) {
View Full Code Here

      return _value.getValue(_evalr, comp);

    Desktop desktop = comp.getDesktop();
    Page page;
    if (desktop == null) {
      Execution exec = Executions.getCurrent();
      if (exec == null)
        throw new IllegalStateException("Not attached, nor execution");
      desktop = exec.getDesktop();
      page = ((ExecutionCtrl)exec).getCurrentPage();
    } else {
      page = comp.getPage();
    }
    return ((WebAppCtrl)desktop.getWebApp()).getUiEngine()
View Full Code Here

    try {
      if (desktop != null) { //recycle
        final Page page = Utils.getMainPage(desktop);
        if (page != null) {
          final Execution exec =
            new ExecutionImpl(svlctx, httpreq, httpres, desktop, page);
          fixContentType(response);
          wappc.getUiEngine()
            .recycleDesktop(exec, page, response.getWriter());
        } else
          desktop = null; //something wrong (not possible; just in case)
      }

      if (desktop == null) {
        desktop = webman.getDesktop(sess, httpreq, httpres, path, true);
        if (desktop == null) //forward or redirect
          return true;

        final RequestInfo ri = new RequestInfoImpl(
          wapp, sess, desktop, httpreq,
          PageDefinitions.getLocator(wapp, path));
        ((SessionCtrl)sess).notifyClientRequest(true);

        final Page page;
        final PageRenderPatch patch = getRenderPatch();
        final Writer out = patch.beforeRender(ri);
        final UiFactory uf = wappc.getUiFactory();
        if (uf.isRichlet(ri, bRichlet)) {
          final Richlet richlet = uf.getRichlet(ri, path);
          if (richlet == null)
            return false; //not found

          page = WebManager.newPage(uf, ri, richlet, httpres, path);
          final Execution exec =
            new ExecutionImpl(svlctx, httpreq, httpres, desktop, page);
          fixContentType(response);
          wappc.getUiEngine().execNewPage(exec, richlet, page,
            out != null ? out: response.getWriter());
        } else if (path != null) {
          final PageDefinition pagedef = uf.getPageDefinition(ri, path);
          if (pagedef == null)
            return false; //not found

          page = WebManager.newPage(uf, ri, pagedef, httpres, path);
          final Execution exec =
            new ExecutionImpl(svlctx, httpreq, httpres, desktop, page);
          fixContentType(response);
          wappc.getUiEngine().execNewPage(exec, pagedef, page,
            out != null ? out: response.getWriter());
        } else
View Full Code Here

  public Zkhead() {
  }

  //Component//
  public void redraw(Writer out) throws IOException {
    final Execution exec = Executions.getCurrent();
    if (exec != null) {
      if (!HtmlPageRenders.isDirectContent(exec))
        throw new UnsupportedOperationException("The parent of zkhead must be head");

      final String zktags = HtmlPageRenders.outHeaderZkTags(exec, getPage());
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.