public void addPage(Page page) { //We have to synchronize it due to getPage allows concurrent access synchronized (_pages) { _pages.add(page); if (log.isDebugEnabled()) log.debug("After added, pages: {}", _pages); } afterPageAttached(page, this); _wapp.getConfiguration().afterPageAttached(page, this); }
public DesktopCache getDesktopCache(Session sess) { final WebApp wapp = sess.getWebApp(); DesktopCache dc = (DesktopCache) wapp.getAttribute(ATTR_CACHE); if (dc == null) { synchronized (this) { dc = (DesktopCache) wapp.getAttribute(ATTR_CACHE); if (dc == null) { dc = new SimpleDesktopCache(sess.getWebApp().getConfiguration()); wapp.setAttribute(ATTR_CACHE, dc); } } } return dc; }
/** Returns the page definition of the specified path, or null if not * found or failed to parse. * * <p>This is the lowest method that other getPageDefinition depends. * * <p>Dependency: Execution.createComponents -& Execution.getPageDefinition * -& UiFactory.getPageDefiition -& PageDefintions.getPageDefinition * * @param locator the locator used to locate taglib and other resources. * If null, wapp is assumed ({@link WebApp} is also assumed). */ public static final PageDefinition getPageDefinition(WebApp wapp, Locator locator, String path) { wapp.getConfiguration().invokeURIInterceptors(path); //give the security a chance to reject return ResourceCaches.get(getCache(wapp), wapp.getServletContext(), path, locator); }
public void stop(WebApp wapp) { DesktopCache dc = (DesktopCache) wapp.getAttribute(ATTR_CACHE); if (dc != null) { wapp.removeAttribute(ATTR_CACHE); dc.stop(); } } }
@SuppressWarnings("unchecked") private static Map<String, EntityManagerFactory> getEmfMap() { Map map = (Map) getWebApp().getAttribute(JPA_EMF_MAP); if (map == null) { map = new HashMap(); getWebApp().setAttribute(JPA_EMF_MAP, map); } return map; }
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); if (autoTimeout != null ? autoTimeout.booleanValue() : wapp.getConfiguration().isAutomaticTimeout(deviceType)) { if (desktop != null) { tmout = desktop.getSession().getMaxInactiveInterval(); tmout = wapp.getConfiguration().getSessionMaxInactiveInterval(); if (tmout <= 0) //system default tmout = hsess.getMaxInactiveInterval(); tmout = wapp.getConfiguration().getSessionMaxInactiveInterval(); sb.append(s).append('\n'); Map<String, DataHandlerInfo> dataHandlers = wapp.getConfiguration().getDataHandlers(); Set<Pair<String, String>> scripts = new LinkedHashSet<Pair<String, String>>(); for (DataHandlerInfo info : dataHandlers.values()) {
final StringBuffer sb = new StringBuffer(256); if (exposeVer) sb.append("\nzkver('").append(wapp.getVersion()).append("','").append(wapp.getBuild()); else sb.append("\nzkver('','"); .append(Encodes.encodeURL(ctx, reqctx.request, reqctx.response, wapp.getUpdateURI(false))); sb.append("ed:'p',"); final Configuration config = wapp.getConfiguration(); int v = config.getProcessingPromptDelay(); if (v != 900)
final Map<String, Object> arg = new HashMap<String, Object>(); arg.put("message", message); arg.put("title", title != null ? title : Executions.getCurrent().getDesktop().getWebApp().getAppName()); arg.put("icon", icon); dlg.setFocus(focus); if (dlg.getDesktop().getWebApp().getConfiguration().isEventThreadEnabled()) { try { dlg.doModal();
try { int hours = 8760; final ThemeProvider tp = getWebApp().getConfiguration().getThemeProvider(); if (tp != null) { final String p = "~." + path; if (tp != null) uri = tp.beforeWidgetCSS(exec, uri); if (uri != null && getWebApp().getResource(uri) != null) _webctx.include(request, HttpBufferedResponse.getInstance(response, sw), uri, null); } catch (Throwable ex) {
public Object getAttribute(String name, boolean recurse) { Object val = getAttribute(name); return val != null || !recurse || _wapp == null ? val : _wapp.getAttribute(name, true); }
if (oldnm == null) oldnm = "ZK"; final String appnm = desktop.getWebApp().getAppName(); if (!oldnm.equals(appnm)) { sb.append("zk.appName='"); 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;
/** Returns the update servlet of the specified application, or * null if not loaded yet. * Note: if the update servlet is not loaded, it returns null. * @since 3.0.2 */ public static DHtmlUpdateServlet getUpdateServlet(WebApp wapp) { return (DHtmlUpdateServlet) (wapp.getServletContext()).getAttribute(ATTR_UPDATE_SERVLET); }
private String getFolderUrl() { String uuid = ((String[])param.get("CKEditor"))[0]; uuid = uuid.substring(0, uuid.lastIndexOf("-cnt")); String url = null; if ("Images".equals(type)) url = (String) session.getAttribute("filebrowserImageBrowseUrl"+ uuid); else if ("Flash".equals(type)) url = (String) session.getAttribute("filebrowserFlashBrowseUrl"+ uuid); if (url == null) url = (String) session.getAttribute("filebrowserBrowseUrl"+ uuid); String updateURI = application.getUpdateURI(); apName = updateURI.substring(0, updateURI.indexOf("/zkau")); int index = url.indexOf(apName); if (index == 0 && apName.length() > 0) index = url.indexOf("/", 1); url = index < 0 ? url: url.substring(index); index = url.lastIndexOf(";jsessionid"); if (index > 0) url = url.substring(0, index); if (application.getResourcePaths(url) == null) throw new UiException("Folder not found: " + url); return url; }
public void init(Page owner, String zslang) { super.init(owner, zslang); if (System.getProperty("python.home") == null) System.setProperty("python.home", System.getProperty("java.io.tmpdir")); PySystemState.initialize(); PySystemState.add_extdir(owner.getDesktop().getWebApp().getRealPath("/WEB-INF/lib"), true); PySystemState.add_classdir(owner.getDesktop().getWebApp().getRealPath("/WEB-INF/classes")); _ip = new PythonInterpreter(new Variables()); }
/** * Loads the content of a file as a String. * * @since 8.5.1 */ public static String loadFileContentAsString(Execution exec, String path) throws IOException { path = exec.locate(path); //ZK-1345: use WebApps.getCurrent() instead of exec.getDesktop().getWebApp() InputStream is = WebApps.getCurrent().getResourceAsStream(path); if (is == null) throw new UiException("Unable to load " + path); final byte[] bs = Files.readAll(is); Files.close(is); return new String(bs, "UTF-8"); //UTF-8 is assumed }
private static String outHost(HttpServletRequest request, WebApp wapp, String clientPackages) { final StringBuffer sb = new StringBuffer().append("zk.setHost('").append(request.getScheme()).append("://") .append(request.getServerName()); if (request.getServerPort() != 80) sb.append(':').append(request.getServerPort()); String uri = request.getContextPath(); if (uri != null && uri.length() > 0) { if (uri.charAt(0) != '/') sb.append('/'); sb.append(uri); removeLast(sb, '/'); } return sb.append("','").append(wapp.getUpdateURI(false)).append("',").append(clientPackages).append(");") .toString(); }
/** Open a download dialog to save the resource of the specified path * at the client. * * @param path the path of the resource. * It must be retrievable by use of {@link org.zkoss.zk.ui.WebApp#getResource}. * @param contentType the content type, e.g., application/pdf. * Unlike other save methods, it is optional. If null, the path's * extension is used to determine the content type. * @exception FileNotFoundException if the resource is not found. * @since 3.0.8 */ public static void save(String path, String contentType) throws FileNotFoundException { final URL url = Executions.getCurrent().getDesktop().getWebApp().getResource(path); if (url == null) throw new FileNotFoundException(path); save(url, contentType); }
@SuppressWarnings("unchecked") private static final ResourceCache<PageDefinition> getCache(WebApp wapp) { ResourceCache<PageDefinition> cache = (ResourceCache<PageDefinition>) wapp.getAttribute(ATTR_PAGE_CACHE); if (cache == null) { synchronized (PageDefinitions.class) { cache = (ResourceCache) wapp.getAttribute(ATTR_PAGE_CACHE); if (cache == null) { ResourceLoader<PageDefinition> loader = null; cache.setMaxSize(1024); cache.setLifetime(60 * 60000); //1hr wapp.setAttribute(ATTR_PAGE_CACHE, cache);
/** * 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); }
final Map aues = (Map) wapp.getAttribute(ATTR_AU_PROCESSORS); if (aues != null) { for (Iterator it = aues.entrySet().iterator(); it.hasNext();) { addAuExtension((String) me.getKey(), (AuExtension) me.getValue()); wapp.removeAttribute(ATTR_AU_PROCESSORS);