示例#1
0
 private static void outDivTemplateEnd(Page page, Writer out) throws IOException {
   final Desktop dt;
   if (page != null && (dt = page.getDesktop()) != null) {
     if (dt.getAttribute(ATTR_DESKTOP_CLIENTINFO) != null) {
       dt.removeAttribute(ATTR_DESKTOP_CLIENTINFO);
       if (!"CE".equals(WebApps.getEdition()))
         out.write(
             "<script type=\"text/javascript\">if(zk.clientinfo === undefined)zk.clientinfo = true;</script>");
     }
     if (dt.getAttribute(ATTR_DESKTOP_VISIBILITYCHANGE) != null) {
       dt.removeAttribute(ATTR_DESKTOP_VISIBILITYCHANGE);
       out.write(
           "<script type=\"text/javascript\">if(zk.visibilitychange === undefined)zk.visibilitychange = true;</script>");
     }
     String resourceURL = (String) page.getAttribute(ATTR_PORTLET2_RESOURCEURL, Page.PAGE_SCOPE);
     if (resourceURL != null) {
       page.removeAttribute(ATTR_PORTLET2_RESOURCEURL, Page.PAGE_SCOPE);
       out.write("<script type=\"text/javascript\">zk.portlet2AjaxURI = '");
       out.write(resourceURL);
       out.write("';</script>");
     }
   }
   outSEOContent(page, out);
   out.write("</div>");
 }
示例#2
0
  /**
   * Generates the special JavaScript code, such as the application's name. It shall be called,
   * before generating "zkmx(" and "zkx(".
   *
   * @since 5.0.6
   */
  public static final String outSpecialJS(Desktop desktop) {
    final StringBuffer sb = new StringBuffer();

    // output application name
    String oldnm = (String) desktop.getAttribute(ATTR_APPNM);
    if (oldnm == null) oldnm = "ZK";
    final String appnm = desktop.getWebApp().getAppName();
    if (!oldnm.equals(appnm)) {
      sb.append("zk.appName='");
      Strings.escape(sb, appnm, Strings.ESCAPE_JAVASCRIPT).append("';");
      desktop.setAttribute(ATTR_APPNM, appnm);
    }

    // output zktheme cookie
    String oldthemenm = (String) desktop.getAttribute(ATTR_THEMENM);
    if (oldthemenm == null) oldthemenm = "";
    final Object request = desktop.getExecution().getNativeRequest();
    String themenm = "";
    if (request instanceof HttpServletRequest) {
      themenm = ThemeFns.getThemeResolver().getTheme((HttpServletRequest) request);
    }
    if (!oldthemenm.equals(themenm)) {
      sb.append("zk.themeName='");
      Strings.escape(sb, themenm, Strings.ESCAPE_JAVASCRIPT).append("';");
      desktop.setAttribute(ATTR_THEMENM, themenm);
    }

    // output ZK ICON
    final Session sess = Sessions.getCurrent();
    if (sess != null) {
      WebApp wapp = desktop.getWebApp();
      if (wapp == null
          || "CE".equals(WebApps.getEdition())
          || wapp.getAttribute("org.zkoss.zk.ui.notice") != null) {
        final PI pi = (PI) sess.getAttribute(ATTR_PI);
        boolean show = pi == null;
        if (show) sess.setAttribute(ATTR_PI, new PI());
        else show = pi.show();
        if (show) sb.append("zk.pi=1;");
      }
    }
    return sb.toString();
  }