/** Returns the main page of the desktop. * It assumes there is at most one main page (that is, a page without owner) */ /*package*/ static Page getMainPage(Desktop desktop) { for (Iterator it = desktop.getPages().iterator(); it.hasNext();) { final Page page = (Page) it.next(); if (((PageCtrl) page).getOwner() == null) return page; } return null; }
public void removePage(Page page) { synchronized (_pages) { if (!_pages.remove(page)) return; //Both UiVisualizer.getResponses and Include.setChildPage //might call removePage if (log.isDebugEnabled()) log.debug("After removed, pages: {}", _pages); } removeComponents(page.getRoots()); afterPageDetached(page, this); ((PageCtrl) page).destroy(); _wapp.getConfiguration().afterPageDetached(page, this); }
/** Returns the content of the specified condition * that will be placed inside the header element of the specified page, * or null if it was generated before. * For HTML, the header element is the HEAD element. * * <p>Notice that this method ignores the following invocations * against the same page in the same execution. In other words, * it is safe to invoke this method multiple times. * * @param before whether to return the headers that shall be shown * before ZK's CSS/JS headers. * If true, only the headers that shall be shown before (such as meta) * are returned. * If true, only the headers that shall be shown after (such as link) * are returned. */ public static final String outHeaders(Execution exec, Page page, boolean before) { if (page == null) return ""; String attr = "zkHeaderGened" + page.getUuid(); if (before) attr += "Bf"; if (exec.getAttribute(attr) != null) return null; exec.setAttribute(attr, Boolean.TRUE); //generated only once return before ? ((PageCtrl) page).getBeforeHeadTags() : ((PageCtrl) page).getAfterHeadTags(); }
final Desktop desktop = page.getDesktop(); final PageCtrl pageCtrl = (PageCtrl) page; final Component owner = pageCtrl.getOwner(); boolean contained = owner == null && exec.isIncluded(); appendProp(props, "ru", desktop.getRequestPath()); final String pageWgtCls = pageCtrl.getWidgetClass(); if (pageWgtCls != null) appendProp(props, "wc", pageWgtCls);
/** * A useful method use to invoke zscript. * @param page page instance. * @param parent The owner of zscript segment. * @param zs A ZScript object. * @throws IOException */ public static void processZScript(Page page, Component parent, ZScript zs) throws IOException { if (zs.getLanguage() == null) zs.setLanguage(page.getZScriptLanguage()); if (zs.isDeferred()) ((PageCtrl)page).addDeferredZScript(parent, zs); else ZkProxy.getProxy().interpret(page, parent, zs); }
private static Boolean getAutomaticTimeout(Desktop desktop) { if (desktop != null) for (Page page : desktop.getPages()) { Boolean b = ((PageCtrl) page).getAutomaticTimeout(); if (b != null) return b; } return null; }
/** Returns the first line to be generated to the output, * or null if no special first line. */ public static final String outFirstLine(Execution exec, Page page) { if (exec.getAttribute(FIRST_LINE_GENED) == null && !exec.isAsyncUpdate(null)) { exec.setAttribute(FIRST_LINE_GENED, Boolean.TRUE); return trimAndLF(((PageCtrl) page).getFirstLine()); } return ""; }
/** Sets the content type to the specified execution for the given page. * @param exec the execution (never null) */ public static final void setContentType(Execution exec, Page page) { String contentType = ((PageCtrl) page).getContentType(); if (contentType == null) { contentType = page.getDesktop().getDevice().getContentType(); if (contentType == null) contentType = ""; } final int j = contentType.indexOf(';'); if (j < 0) { final String cs = page.getDesktop().getWebApp().getConfiguration().getResponseCharset(); if (cs != null && cs.length() > 0) contentType += ";charset=" + cs; } ((ExecutionCtrl) exec).setContentType(contentType); }
/** Returns the doc type, or null if not available. * It is null or <!DOCTYPE ...>. */ public static final String outDocType(Execution exec, Page page) { if (exec.getAttribute(DOCTYPE_GENED) == null && !exec.isAsyncUpdate(null)) { exec.setAttribute(DOCTYPE_GENED, Boolean.TRUE); final String docType = ((PageCtrl) page).getDocType(); return trimAndLF(docType != null ? docType : page.getDesktop().getDevice().getDocType()); } return ""; }
if (isEffective(zsInfo, page, comp)) { if (zsInfo.isDeferred()) { ((PageCtrl) page).addDeferredZScript(comp, zsInfo.getZScript());
public void invalidate() { for (Page page : _pages) if (((PageCtrl) page).getOwner() == null) page.invalidate(); }
for (Page page : pages) { try { ((PageCtrl) page).destroy(); } catch (Throwable ex) { log.warn("Failed to destroy " + page, ex);
/** Renders the page if {@link Page#isComplete} is false. * * @param au whether it is caused by an asynchronous update */ protected void renderPage(Execution exec, Page page, Writer out, boolean au) throws IOException { if (!au) { out.write(HtmlPageRenders.outLangStyleSheets(exec, null, null)); out.write(HtmlPageRenders.outLangJavaScripts(exec, null, null)); } HtmlPageRenders.outPageContent(exec, page, out, au); if (!au && ((PageCtrl) page).getOwner() == null) writeln(out, HtmlPageRenders.outUnavailable(exec)); }
/** * Renders the page if {@link Page#isComplete} is false. * * @param au * whether it is caused by an asynchronous update */ protected void renderPage(Execution exec, Page page, Writer out, boolean au) throws IOException { if (!au) { out.write(HtmlPageRenders.outLangStyleSheets(exec, null, null)); out.write(HtmlPageRenders.outLangJavaScripts(exec, null, null)); } HtmlPageRenders.outPageContent(exec, page, out, au); if (!au && ((PageCtrl) page).getOwner() == null) writeln(out, HtmlPageRenders.outUnavailable(exec)); }
Set<Page> pages = null; for (Page page : desktop.getPages()) { final Component owner = ((PageCtrl) page).getOwner(); if (owner != null) { //included final Page ownerPage = owner.getPage(); for (Iterator<Page> it = pages.iterator(); it.hasNext();) { final Page page = it.next(); final Component owner = ((PageCtrl) page).getOwner(); if (_pgRemoved.contains(owner.getPage())) { it.remove();
/** Generates the SEO content for the given page. * Nothing is generated if the SEO content has been generated or it shall not be generated. * <p>The SEO content shall be placed inside <code><div class="z-temp"></code>. * <p>If a page renderer generates <code><div class="z-temp"></code> by itself, * it must invoke this method. * @since 5.0.9 */ public static void outSEOContent(Page page, Writer out) throws IOException { if (page != null && ((PageCtrl) page).getOwner() == null) { //only the topmost page shall generate SEO final SEORenderer[] sds = page.getDesktop().getWebApp().getConfiguration().getSEORenderers(); for (int j = 0; j < sds.length; ++j) sds[j].render(page, out); } }