/** 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 true. * In other words, the page content contains HTML/BODY tags. */ protected void renderComplete(Execution exec, Page page, Writer out) throws IOException { write(out, HtmlPageRenders.outFirstLine(exec, page)); //might null write(out, HtmlPageRenders.outDocType(exec, page)); //might null HtmlPageRenders.setContentType(exec, page); for (Component root = page.getFirstRoot(); root != null; root = root.getNextSibling()) ((ComponentCtrl) root).redraw(out); write(out, HtmlPageRenders.outHeaderZkTags(exec, page)); writeln(out, HtmlPageRenders.outUnavailable(exec)); } }
private static void outHeaders(Execution exec, Page page, Writer out) throws IOException { out.write(HtmlPageRenders.outHeaders(exec, page, true)); //F70-ZK-2495: place init-crash-script before zk.wpd out.write(HtmlPageRenders.outInitCrashScript(exec, null)); out.write(HtmlPageRenders.outLangJavaScripts(exec, null, null)); out.write(HtmlPageRenders.outLangStyleSheets(exec, null, null)); out.write(HtmlPageRenders.outHeaders(exec, page, false)); }
/** Generates and returns the ZK specific HTML tags including * the headers defined in the specified page, or null if it was * generated before. * * <p>It is shortcut of<br/> *<code>outZkHeader(exec, page, true)+outZkTags(exec, null, null)+outZkHeader(exec, page, false)</code> * * <p>Unlike {@link #outZkTags}, this method cannot be called * in JSP/DSP (since desktop is not available). * * @see #outZkTags */ public static String outHeaderZkTags(Execution exec, Page page) { String s1 = outHeaders(exec, page, true), s2 = outZkTags(exec, null, null), s3 = outHeaders(exec, page, false); return s1 != null ? s2 != null ? s3 != null ? s1 + s2 + s3 : s1 + s2 : s3 != null ? s1 + s3 : s1 : //s2 null s2 != null ? s3 != null ? s2 + s3 : s2 : s3 != null ? s3 : null; //s2 null }
public void render(Page page, Writer out) throws IOException { out.write(HtmlPageRenders.outLangStyleSheets(_exec, null, null)); out.write(HtmlPageRenders.outLangJavaScripts(_exec, null, null)); if (_pageDOM) { HtmlPageRenders.outPageContent(_exec, page, out, false); return; } final Desktop desktop = _exec.getDesktop(); out.write("<script class=\"z-runonce\" type=\"text/javascript\">zkpb('"); out.write(page.getUuid()); out.write("','"); out.write(desktop.getId()); out.write("','"); out.write(getContextURI()); out.write("','"); out.write(desktop.getUpdateURI(null)); out.write("','"); out.write(desktop.getRequestPath()); out.write('\''); String style = page.getStyle(); if (style != null && style.length() > 0) { out.write(",{style:'"); out.write(style); out.write("'}"); } out.write(");zkpe();</script>\n"); for (Component root = page.getFirstRoot(); root != null; root = root.getNextSibling()) { HtmlPageRenders.outStandalone(_exec, root, out); } }
final Desktop desktop = exec.getDesktop(); out.write(HtmlPageRenders.outHeaders(exec, page, true)); out.write(HtmlPageRenders.outLangStyleSheets(exec, null, null)); out.write(HtmlPageRenders.outLangJavaScripts(exec, null, null)); out.write(HtmlPageRenders.outHeaders(exec, page, false)); out.write(HtmlPageRenders.outResponseJavaScripts(exec));
final boolean root = getParent() == null && (getPage().isComplete() || (exec != null && "complete".equals(ExecutionsCtrl.getPageRedrawControl(exec)))); if (exec == null || exec.isAsyncUpdate(null) || (!root && !HtmlPageRenders.isDirectContent(exec))) { super.redraw(out); //renderProperties (assume in zscript) return; if (exec != null && !HtmlPageRenders.isZkTagsGenerated(exec) && exec.getAttribute(ATTR_TOP_NATIVE) == null) { //need to check topmost native only String tn; if (root || "html".equals(tn = _tag != null ? _tag.toLowerCase(java.util.Locale.ENGLISH) : "") HtmlPageRenders.outStandalone(exec, null, out); } else { if (root) HtmlPageRenders.setDirectContent(exec, true); do { Component next = child.getNextSibling(); ((ComponentCtrl) child).redraw(out); } else { HtmlPageRenders.setDirectContent(exec, false); HtmlPageRenders.outStandalone(exec, child, out); HtmlPageRenders.setDirectContent(exec, true); if (!HtmlPageRenders.isZkTagsGenerated(exec)) { int jhead = -1, //anchor of header junav = -1, //anchor of unavailable final String msg = HtmlPageRenders.outUnavailable(exec);
exec.setAttribute(ATTR_ZK_TAGS_GENERATED, Boolean.TRUE); final StringBuffer sb = new StringBuffer(512).append('\n').append(outLangJavaScripts(exec, wapp, deviceType)) .append(outLangStyleSheets(exec, wapp, deviceType)); .append("','").append(getContextURI(exec)).append("','").append(desktop.getUpdateURI(null)) .append("','").append(desktop.getRequestPath()).append("');").append(outSpecialJS(desktop)) .append("\n</script>\n");
HtmlPageRenders.setContentType(exec, page); write(out, HtmlPageRenders.outFirstLine(exec, page)); //might null write(out, HtmlPageRenders.outDocType(exec, page)); //might null Double number = exec.getBrowser("mobile"); HtmlPageRenders.outPageContent(exec, page, out, false); writeln(out, HtmlPageRenders.outUnavailable(exec));
rc = new RenderContext(out, new StringWriter(), desktop.getWebApp().getConfiguration().isCrawlable(), false); setRenderContext(exec, rc); } else if (owner != null) { old = getRenderContext(exec); //store final boolean crawlable = old != null && old.temp != null && desktop.getWebApp().getConfiguration().isCrawlable(); setRenderContext(exec, crawlable ? new RenderContext(old.temp, null, true, true) : null); outDivTemplateBegin(out, page.getUuid()); outDivTemplateEnd(page, out); //close it now since no rc.temp out.write('['); else { out.write(outSpecialJS(desktop)); 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()); appendProp(props, "wc", pageWgtCls);
/** Returns HTML tags to include JavaScript files of the specified * device for the current application (never null). * @since 5.0.0 */ public static final String outDeviceJavaScripts(String deviceType) { final Execution exec = Executions.getCurrent(); if (exec != null) return HtmlPageRenders.outLangJavaScripts(exec, null, null); return JspFns.outDeviceJavaScripts(ServletFns.getCurrentServletContext(), (HttpServletRequest) ServletFns.getCurrentRequest(), (HttpServletResponse) ServletFns.getCurrentResponse(), deviceType); }
public void redraw(Writer out) throws IOException { final Execution exec = Executions.getCurrent(); if (exec != null) { if (!HtmlPageRenders.isDirectContent(exec)) throw new UnsupportedOperationException("The parent of zkhead must be head"); final String zktags = HtmlPageRenders.outHeaderZkTags(exec, getPage()); if (zktags != null) out.write(zktags); } }
/** Returns HTML tags to include style sheets of the specified device * for the current application (never null). * * <p>This method is used for DSP pages. * @param deviceType the device type. If null, ajax is assumed. */ public static final String outDeviceStyleSheets(String deviceType) { final Execution exec = Executions.getCurrent(); if (exec != null) return HtmlPageRenders.outLangStyleSheets(exec, null, null); return JspFns.outDeviceStyleSheets(ServletFns.getCurrentServletContext(), (HttpServletRequest) ServletFns.getCurrentRequest(), (HttpServletResponse) ServletFns.getCurrentResponse(), deviceType); }
write(out, HtmlPageRenders.outHeaderZkTags(exec, page)); if (rcs.length() == 0) { Object notice = webApp.getAttribute("org.zkoss.zk.ui.client.notice"); writeln(out, HtmlPageRenders.outUnavailable(exec)); afterRenderTag(exec, param);
/** * Renders the children directly to the given output. Notice it is called only if * {@link #redraw} is going to render the content (HTML tags) directly. If it is about to * generate the JavaScript code {@link #redrawChildren} will be called instead. * <p> * You have to override this method if the deriving class has additional information to render. * * @since 5.0.7 */ protected void redrawChildrenDirectly(TagRenderContext rc, Execution exec, java.io.Writer out) throws java.io.IOException { for (Component child = getFirstChild(); child != null;) { Component next = child.getNextSibling(); if (((ComponentCtrl) child).getExtraCtrl() instanceof DirectContent) { ((ComponentCtrl) child).redraw(out); } else { HtmlPageRenders.setDirectContent(exec, false); rc.renderBegin(child, null, getSpecialRendererOutput(child), true); HtmlPageRenders.outStandalone(exec, child, out); rc.renderEnd(child); HtmlPageRenders.setDirectContent(exec, true); } child = next; } }
/** Generates the AU responses that are part of a page rendering. * Notice that {@link #outPageContent} will invoke this method automatically. * <p>It is the same as <code>outResponseJavaScripts(exec, false)</code>. */ public static final String outResponseJavaScripts(Execution exec) { return outResponseJavaScripts(exec, false); }
/** Render the crawlable HTML A tag. * If crawlable is not enabled or href is empty, nothing is generated. * * @param href the hyper link. If null or empty, nothing is generated. * @param label the label to show. Empty is assumed if null. * @since 5.0.0 */ public static void renderCrawlableA(String href, String label) throws IOException { if (href != null && href.length() > 0) { final HtmlPageRenders.RenderContext rc = HtmlPageRenders.getRenderContext(null); if (rc != null && rc.crawlable) { final Writer cwout = rc.temp; cwout.write("<a href=\""); cwout.write(href); cwout.write("\">"); cwout.write(label != null ? label : ""); cwout.write("</a>\n"); } } }
/** * Adds both headers and other ZK-related tags. * * @param tag * the tag name, such as "head", "body" and "html" */ /* package */ static void addAllZkTags(Execution exec, Page page, StringBuffer buf, String tag) { addHeaderZkTags(exec, page, buf, tag); final String msg = HtmlPageRenders.outUnavailable(exec); if (msg != null && msg.length() > 0) { final int j = buf.lastIndexOf("</" + tag + '>'); if (j >= 0) buf.insert(j, msg); else buf.append(msg); } } }
public void redraw(java.io.Writer out) throws java.io.IOException { if (!HtmlPageRenders.isDirectContent(null)) throw new UnsupportedOperationException("Parent of title must be head"); super.redraw(out); out.write('\n'); } }
/** Returns HTML tags to include JavaScript files of the specified * device for the current application (never null). * @since 5.0.0 */ public static final String outDeviceJavaScripts(ServletContext ctx, HttpServletRequest request, HttpServletResponse response, String deviceType) { Execution old = Executions.getCurrent(); Execution exec = new ExecutionImpl(ctx, request, response, null, null); ExecutionsCtrl.setCurrent(exec); ((ExecutionCtrl) exec).onActivate(); try { return HtmlPageRenders.outLangJavaScripts(exec, WebManager.getWebManager(ctx).getWebApp(), deviceType != null ? deviceType : "ajax"); } finally { ((ExecutionCtrl) exec).onDeactivate(); ExecutionsCtrl.setCurrent(old); } }