/** Returns the build identifier, such as 2007121316. * * <p>Each time ZK is built, a different build identifier is assigned. * @since 6.0.3 */ public static String getBuild() { return WebApps.getCurrent().getBuild(); }
private RenderContext(Writer temp, Writer perm, boolean crawlable, boolean included) { this.temp = temp; this.perm = perm; if (crawlable && WebApps.getFeature("ee")) { this.crawlable = crawlable; } else this.crawlable = false; this.included = included; } }
/** Returns the edition, such as EE, PE and CE. * Notice that prior to 5.0.1, the return value is one of * Enterprise, Professional and Standard. * @since 6.0.3 */ public static String getEdition() { return WebApps.getEdition(); }
/** Returns the ZK version, such as "1.1.0" and "2.0.0". * @since 6.0.3 */ public static String getVersion() { return WebApps.getCurrent().getVersion(); }
private static boolean disableFeature() { return !WebApps.getFeature("ee"); }
/** Returns the string encoded with ZK. * @since 6.0.3 */ public static String encodeWithZK(String name) { if (name.startsWith("zk")) return "zk" + (WebApps.getEdition().toLowerCase(java.util.Locale.ENGLISH)) + name.substring(2); return "zk" + (WebApps.getEdition().toLowerCase(java.util.Locale.ENGLISH)) + name; } }
/** * Returns the edition whether valid or invalid. * @since 6.5.5 */ public static boolean isEditionValid() { WebApp current = WebApps.getCurrent(); return !("CE".equals(getEdition()) || current == null || current.getAttribute("org.zkoss.zk.ui.notice") == null); }
/** Sets whether this Web application is crawlable. * Make a Web application that allows search engines to crawl the application. * Notice that there is some performance loss for huge web pages. (EE only) * @since 5.0.0 */ public void setCrawlable(boolean crawlable) { if (crawlable && !WebApps.getFeature("ee")) { log.warn("The crawlable setting is for EE edtion only!"); return; } _crawlable = crawlable; }
/** Returns the prefix of URL to represent this build. */ private String getCWRURLPrefix() { int code = _wapp.getVersion().hashCode() ^ _wapp.getBuild().hashCode() ^ WebApps.getEdition().hashCode(); for (Iterator<LanguageDefinition> it = LanguageDefinition.getAll().iterator(); it.hasNext();) { final LanguageDefinition langdef = it.next(); for (Iterator e = langdef.getJavaScriptModules().entrySet().iterator(); e.hasNext();) { final Map.Entry me = (Map.Entry) e.next(); code ^= Objects.hashCode(me.getKey()) + Objects.hashCode(me.getValue()); } for (Iterator e = langdef.getMergedJavaScriptPackages("zk").iterator(); e.hasNext();) { code ^= Objects.hashCode(e.next()); } } return Integer.toHexString(code); //FF 8-char boundary: http://code.google.com/intl/de/speed/page-speed/docs/caching.html }
@Override public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) { HttpSession httpSession = (HttpSession) request.getHttpSession(); org.zkoss.zk.ui.Session sess = SessionsCtrl.getSession(WebApps.getCurrent(), httpSession); config.getUserProperties().put(getClass().getName(), sess); }
/** * Generates the ZK feature information * @since 6.5.1 */ public static final String outFeature() { final StringBuffer sb = new StringBuffer(32); sb.append("if(!zk.feature)zk.feature = {standard:true"); if (WebApps.getFeature("ee")) sb.append(",ee:true"); else if (WebApps.getFeature("pe")) sb.append(",pe:true"); sb.append("};"); return sb.toString(); }
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);
private void beforeComponentPageChanged(Page page) { //ZK-1148, add a @destroy annotation method. if (page == null) WebApps.getCurrent().getConfiguration().invokeCallback("destroy", this); } private void afterComponentPageChanged(Page newpg, Page oldpg) {
/** * Returns Specifies how many pages (of treeitems) to keep rendered in memory * (on the server side) when navigating the tree using pagination. * <p> * Default: 1. (Since 7.0.0) * <p> * It is used only if live data ({@link #setModel(ListModel)} and in paging mold * ({@link #getPagingChild}. */ private int maxRodPageSize() { if (WebApps.getFeature("ee")) { return Utils.getIntAttribute(this, "org.zkoss.zul.tree.maxRodPageSize", INIT_LIMIT, true); } return -1; }
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), namespace = (String) page.getAttribute(ATTR_PORTLET2_NAMESPACE, Page.PAGE_SCOPE); if (resourceURL != null) { page.removeAttribute(ATTR_PORTLET2_RESOURCEURL, Page.PAGE_SCOPE); page.removeAttribute(ATTR_PORTLET2_NAMESPACE, Page.PAGE_SCOPE); // B65-ZK-2210: store url and namespace per desktop. out.write("<script type=\"text/javascript\">if(!zk.portlet2Data) zk.portlet2Data = {};\n" + "zk.portlet2Data['" + dt.getId() + "'] = {" + "resourceURL: '" + resourceURL + "', " + "namespace: '" + namespace + "'};</script>"); } } outSEOContent(page, out); out.write("</div>"); }
/** Default: If parent is null, execute the @Destroy method if any. * @see ComponentCtrl#beforeParentChanged * @since 3.6.2 */ public void beforeParentChanged(Component parent) { //ZK-1148, add a @destroy annotation method. if (parent == null)//detach WebApps.getCurrent().getConfiguration().invokeCallback("destroy", this); }
/** * Returns the number of items rendered when the Tree first render. * <p> * Default: 50. (Since 7.0.0) * <p> * It is used only if live data ({@link #setModel(ListModel)} and not paging * ({@link #getPagingChild}. */ private int initRodSize() { if (WebApps.getFeature("ee")) { // ZK-2165: should return page size in paging mold if (inPagingMold()) return getPageSize(); else return Utils.getIntAttribute(this, "org.zkoss.zul.tree.initRodSize", INIT_LIMIT, true); } return -1; }
throw new UiException("Only one Web manager is allowed in one context: " + ctx); log.info("Starting ZK " + org.zkoss.zk.Version.RELEASE + ' ' + WebApps.getEdition() + " (build: " + org.zkoss.zk.ui.impl.AbstractWebApp.loadBuild() + ')');
/** * Generates moment.js and moment-timezone-with-data.js string. * * @since 8.5.1 */ public static final String outMomentJavascript(ServletRequest request, ServletResponse response) throws IOException { final StringBuffer result = new StringBuffer(); final WebApp webApp = WebApps.getCurrent(); final Execution exec = new FakeExecution(webApp.getServletContext(), request, response, null, null); result.append("if (!zk.mm) { var temp; if (window.moment) { temp = window.moment; }"); result.append(Devices.loadJavaScript(exec, "~./js/zk/ext/moment.js")); result.append(Devices.loadJavaScript(exec, "~./js/zk/ext/moment-timezone-with-data.js")); result.append("zk.mm = window.moment; window.moment = temp; }"); String path = Library.getProperty("org.zkoss.zk.moment.timezone.path"); if (path != null) { String json = null; try { json = Devices.loadFileContentAsString(exec, path); } catch (Exception e) { log.warn(e.getMessage()); } if (json != null) { result.append("var tzdata ="); result.append(json); result.append("; zk.mm.tz.load(tzdata);"); } } return result.toString(); }
if (WebApps.getFeature("ee")) sb.append("ed:'e',"); else if (WebApps.getFeature("pe")) sb.append("ed:'p',");