Package org.zkoss.zk.ui

Examples of org.zkoss.zk.ui.Desktop


        _desktops.disableExpunge(old);
      }
    }
  }
  public Desktop getDesktop(String desktopId) {
    final Desktop desktop;
    synchronized (_desktops) {
      desktop = (Desktop)_desktops.get(desktopId);
    }
    if (desktop == null)
      throw new ComponentNotFoundException("Desktop not found: "+desktopId);
View Full Code Here


    final boolean bInclude = Servlets.isIncluded(request);
    final boolean compress = _compress && !bInclude;
    final Writer out = compress ? (Writer)new StringWriter(): response.getWriter();
    final DesktopRecycle dtrc = bInclude ? null: config.getDesktopRecycle();
    Desktop desktop = dtrc != null ?
      Utils.beforeService(dtrc, _ctx, sess, request, response, path): null;

    try {
      if (desktop != null) { //recycle
        final Page page = Utils.getMainPage(desktop);
View Full Code Here

    final WebAppCtrl wappc = (WebAppCtrl)wapp;
    final Session sess = webman.getSession(_ctx, request);
    final Object old = I18Ns.setup(sess, request, response, _charset);
    try {
      final String path = Https.getThisServletPath(request);
      final Desktop desktop =
        webman.getDesktop(sess, request, response, path, true);
      if (desktop == null) //forward or redirect
        return;

      final RequestInfo ri = new RequestInfoImpl(
View Full Code Here

  private String getEncodedURL() {
    if (getContent() != null) //allow derived to override getContent()
      return Utils.getDynamicMediaURI(this, _cntver, "css", "css");

    if (_src != null) {
      final Desktop dt = getDesktop();
      if (dt != null)
        return dt.getExecution().encodeURL(_src);
    }
    return "";
  }
View Full Code Here

    }
  }
  /** Returns the encoded src ({@link #getSrc}).
   */
  protected String getEncodedSrc() {
    final Desktop dt = getDesktop();
    return _media != null ? getMediaSrc(): //already encoded
      dt != null && _src != null ?
        dt.getExecution().encodeURL(_src)"";
  }
View Full Code Here

    }
  }

  //Bug #2871082
  private String getEncodedHref() {
    final Desktop dt = getDesktop();
    return _href != null && dt != null ? dt.getExecution().encodeURL(_href): null;
      //if desktop is null, it doesn't belong to any execution
  }
View Full Code Here

    //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

  String outLangJavaScripts(Execution exec, WebApp wapp, String deviceType) {
    if (exec.getAttribute(ATTR_LANG_JS_GENED) != null)
      return ""; //nothing to generate
    exec.setAttribute(ATTR_LANG_JS_GENED, Boolean.TRUE);

    final Desktop desktop = exec.getDesktop();
    if (wapp == null) wapp = desktop.getWebApp();
    if (deviceType == null)
      deviceType = desktop != null ? desktop.getDeviceType(): "ajax";

    final StringBuffer sb = new StringBuffer(1536);

    final Set jses = new LinkedHashSet(32);
    for (Iterator it = LanguageDefinition.getByDeviceType(deviceType).iterator();
    it.hasNext();)
      jses.addAll(((LanguageDefinition)it.next()).getJavaScripts());
    for (Iterator it = jses.iterator(); it.hasNext();)
      append(sb, (JavaScript)it.next());

    sb.append("\n<!-- ZK ").append(wapp.getVersion());
    if (WebApps.getFeature("ee"))
      sb.append(" EE");
    else if (WebApps.getFeature("pe"))
      sb.append(" PE");
    sb.append(' ').append(wapp.getBuild());
    Object o = wapp.getAttribute("org.zkoss.zk.ui.notice");
    if (o != null) sb.append(o);
    sb.append(" -->\n");

    int tmout = 0;
    if (desktop != null) {
      final Boolean autoTimeout = getAutomaticTimeout(desktop);
      if (autoTimeout != null ?
      autoTimeout.booleanValue():
      wapp.getConfiguration().isAutomaticTimeout(deviceType)) {
        tmout = desktop.getSession().getMaxInactiveInterval();
        if (tmout > 0) { //unit: seconds
          int extra = tmout / 8;
          tmout += extra > 180 ? 180: extra;
            //Add extra seconds to ensure it is really timeout
        }
View Full Code Here

   * @param exec the execution (never null)
   */
  public static final
  void outPageContent(Execution exec, Page page, Writer out, boolean au)
  throws IOException {
    final Desktop desktop = page.getDesktop();
    final PageCtrl pageCtrl = (PageCtrl)page;
    final Component owner = pageCtrl.getOwner();
    boolean contained = owner == null && exec.isIncluded();
      //a standalong page (i.e., no owner), and being included by
      //non-ZK page (e.g., JSP).
      //
      //Revisit Bug 2001707: OK to use exec.isIncluded() since
      //we use PageRenderer now (rather than Servlet's include)
      //TODO: test again

    //prepare style
    String style = page.getStyle();
    if (style == null || style.length() == 0) {
      style = null;
      String wd = null, hgh = null;
      if (owner instanceof HtmlBasedComponent) {
        final HtmlBasedComponent hbc = (HtmlBasedComponent)owner;
        wd = hbc.getWidth(); //null if not set
        hgh = hbc.getHeight(); //null if not set
      }

      if (wd != null || hgh != null || contained) {
        final StringBuffer sb = new StringBuffer(32);
        HTMLs.appendStyle(sb, "width", wd != null ? wd: "100%");
        HTMLs.appendStyle(sb, "height",
          hgh != null ? hgh: contained ? null: "100%");
        style = sb.toString();
      }
    }

    RenderContext rc = null, old = null;
    final boolean divRequired = !au || owner != null;
    final boolean standalone = !au && owner == null;
    if (standalone) {
      rc = new RenderContext(
        out, desktop.getWebApp().getConfiguration().isCrawlable());
      setRenderContext(exec, rc);
    } else if (owner != null) {
      old = getRenderContext(exec); //store
      setRenderContext(exec, null);
    }

    //generate div first
    if (divRequired) {
      outDivTemplateBegin(out, page.getUuid());
    }
    if (standalone) { //switch out
      //don't call outDivTemplateEnd yet since rc.temp will be generated before it
      out = new StringWriter();
    } else if (divRequired) {
      outDivTemplateEnd(out); //close it now since no rc.temp
    }

    //generate JS second
    final boolean aupg = exec.isAsyncUpdate(page); //AU this page
    if (divRequired) {
      out.write("\n<script type=\"text/javascript\">");
      if (!aupg && owner != null) {
        out.write("zkq('");
        out.write(owner.getUuid());
        out.write("',function(){");
      }
      out.write(outZkIconJS());
    }

    exec.setAttribute(ATTR_DESKTOP_JS_GENED, Boolean.TRUE);
    final int order = ComponentRedraws.beforeRedraw(false);
    final String extra;
    try {
      if (order < 0)
        out.write(aupg ? "[": divRequired ? "zkmx(": "zkx(");
      else if (order > 0) //not first child
        out.write(',');
      out.write("\n[0,'"); //0: page
      out.write(page.getUuid());
      out.write("',{");

      final StringBuffer props = new StringBuffer(128);
      final String pgid = page.getId();
      if (pgid.length() > 0)
        appendProp(props, "id", pgid);
      if (owner != null) {
        appendProp(props, "ow", owner.getUuid());
      } else {
        appendProp(props, "dt", desktop.getId());
        appendProp(props, "cu", getContextURI(exec));
        appendProp(props, "uu", desktop.getUpdateURI(null));
        appendProp(props, "ru", desktop.getRequestPath());
      }
      if (style != null)
        appendProp(props, "style", style);
      if (!isClientROD(page))
        appendProp(props, "z$rod", Boolean.FALSE);
View Full Code Here

    final StringBuffer sb = new StringBuffer(512).append('\n')
      .append(outLangStyleSheets(exec, wapp, deviceType))
      .append(outLangJavaScripts(exec, wapp, deviceType));

    final Desktop desktop = exec.getDesktop();
    if (desktop != null && exec.getAttribute(ATTR_DESKTOP_JS_GENED) == null) {
      sb.append("<script type=\"text/javascript\">zkdt('")
        .append(desktop.getId()).append("','")
        .append(getContextURI(exec))
        .append("','").append(desktop.getUpdateURI(null))
        .append("');").append(outZkIconJS())
        .append("</script>\n");
    }

    return sb.toString();
View Full Code Here

TOP

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

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.