Package org.zkoss.zk.ui.sys

Examples of org.zkoss.zk.ui.sys.UiEngine


  protected void response(String key, AuResponse response) {
    //if response not depend on this component, it must be generated
    if (_page != null) {
      getAttachedUiEngine().addResponse(key, response);
    } else if (response.getDepends() != this) {
      final UiEngine uieng = getCurrentUiEngine();
      if (uieng != null) uieng.addResponse(key, response);
    }
  }
View Full Code Here


        invalidate();
    }
  }

  public boolean disableClientUpdate(boolean disable) {
    final UiEngine uieng =
      _page != null ? getAttachedUiEngine(): getCurrentUiEngine();
    return uieng != null && uieng.disableClientUpdate(this, disable);
  }
View Full Code Here

    render(renderer, "comment", _comment);

    if (_instantMode &&_afterComposed)
      return; //instant mode (done by redrawChildren())

    final UiEngine ueng =
      ((WebAppCtrl)getDesktop().getWebApp()).getUiEngine();
    Component old = ueng.setOwner(this);
    try {
      if (_progressStatus == 1) {
        _progressStatus = 2;
      } else if (_src != null && _src.length() > 0) {
        final StringWriter sw = new StringWriter();
        include(sw);

        //Don't output sw directly if getChildPage() is not null
        //Otherwise, script of the included zul page will be evaluated
        //first (since it is part of rc.temp)

        boolean done = false;
        if (getChildPage() == null) { //only able to handle non-ZUL page
          final HtmlPageRenders.RenderContext rc =
            HtmlPageRenders.getRenderContext(null);
          if (rc != null) {
            final Writer cwout = rc.temp;
            cwout.write("<div id=\"");
            cwout.write(getUuid());
            cwout.write("\" style=\"display:none\">");
            if (_comment)
              cwout.write("\n<!--\n");
            Files.write(cwout, sw.getBuffer());
            if (_comment)
              cwout.write("\n-->\n");
            cwout.write("</div>");

            renderer.render("z$ea", "content");
            done = true;
          }
        }
        if (!done)
          renderer.render("content", sw.toString());
      }
    } finally {
      ueng.setOwner(old);
    }
  }
View Full Code Here

   * @exception IllegalStateException if there is suspended thread
   * and use is false.
   */
  public void enableEventThread(boolean enable) {
    if (!enable && _wapp != null) {
      final UiEngine engine = ((WebAppCtrl)_wapp).getUiEngine();
      if (engine != null) {
        if (engine.hasSuspendedThread())
          throw new IllegalStateException("Unable to disable due to suspended threads");
      }
    }
    _useEvtThd = enable;
  }
View Full Code Here

    }
  }
  /** Safe to be called even if the Web application has been destroyed
   */
  private void safeActivate(Execution exec) {
    final UiEngine uieng = ((WebAppCtrl)_wapp).getUiEngine();
    if (uieng != null) {
      uieng.activate(exec);
    } else {
      _exec = exec;
      ExecutionsCtrl.setCurrent(exec);
    }
  }
View Full Code Here

    }
  }
  /** Safe to be called even if the Web application has been destroyed
   */
  private void safeDeactivate(Execution exec) {
    final UiEngine uieng = ((WebAppCtrl)_wapp).getUiEngine();
    if (uieng != null) {
      uieng.deactivate(exec);
    } else {
      _exec = null;
      ExecutionsCtrl.setCurrent(null);
    }
  }
View Full Code Here

    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);

        media = desktopCtrl.getDownloadMedia(uuid, false);
        if (media != null) {
          download = true; //yes, it is for download
        } else {
          final Component comp = desktop.getComponentByUuid(uuid);
          final Object cc = ((ComponentCtrl)comp).getExtraCtrl();
          if (!(cc instanceof DynamicMedia))
            throw new ServletException(DynamicMedia.class+" must be implemented by getExtraCtrl() of "+comp);
          media = ((DynamicMedia)cc).getMedia(l >= 0 ? pi.substring(l): "");
          if (media == null) {
            response.sendError(response.SC_GONE, Messages.get(MZk.PAGE_NOT_FOUND, pi+" - "+comp));
            return;
          }
        }
      } catch (Throwable ex) {
        err = true;

        final List errs = new LinkedList();
        errs.add(ex);
        desktopCtrl.invokeExecutionCleanups(exec, oldexec, errs);
        config.invokeExecutionCleanups(exec, oldexec, errs);

        final StringBuffer errmsg = new StringBuffer(100);
        if (!errs.isEmpty()) {
          for (Iterator it = errs.iterator(); it.hasNext();) {
            final Throwable t = (Throwable)it.next();
            log.realCauseBriefly("Failed to load media, "+pi, t);
            errmsg.append('\n').append(Exceptions.getMessage(t));
          }
        }

        response.sendError(response.SC_GONE,
          Messages.get(MZk.PAGE_FAILED, new Object[] {pi, errmsg, ""}));
        return;
      } finally {
        if (!err) {
          desktopCtrl.invokeExecutionCleanups(exec, oldexec, null);
          config.invokeExecutionCleanups(exec, oldexec, null);
        }
        uieng.deactivate(exec);
      }
    } catch (ComponentNotFoundException ex) {
      //possible because view might be as late as origin comp is gone
      response.sendError(response.SC_GONE, Messages.get(MZk.UPDATE_OBSOLETE_PAGE, uuid));
      return;
View Full Code Here

TOP

Related Classes of org.zkoss.zk.ui.sys.UiEngine

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.