/** * Ends and cleans up the rendering of a ZHTML tag. * * @param param * the value returned by {@link #beforeRenderHtml}. */ public static void afterRenderTag(Execution exec, Object param) { if (param != null) exec.setAttribute(ATTR_RENDER_CONTEXT, null); }
public void setAttribute(Execution exec, String name, Object value) { exec.setAttribute(name, value); } public void removeAttribute(Execution exec, String name) {
private static final void setRenderContext(Execution exec, RenderContext rc) { exec.setAttribute(ATTR_RENDER_CONTEXT, rc); }
/** Sets whether a component can directly generate HTML tags * to the output. * @see #isDirectContent */ public static boolean setDirectContent(Execution exec, boolean direct) { return (direct ? exec.setAttribute(ATTR_DIRECT_CONTENT, Boolean.TRUE) : exec.removeAttribute(ATTR_DIRECT_CONTENT)) != null; }
private static void restoreDynams(Execution exec, Map<String, Object> old) { if (old != null) for (Map.Entry<String, Object> me : old.entrySet()) { final String nm = me.getKey(); final Object val = me.getValue(); if (val != null) exec.setAttribute(nm, val); else exec.removeAttribute(nm); } }
public Object setAttribute(String name, Object value) { return exec().setAttribute(name, value); }
public Object setAttribute(String name, Object value, boolean recurse) { return exec().setAttribute(name, value, recurse); }
private Map<String, Object> setupDynams(Execution exec) { if (_dynams == null || _dynams.isEmpty()) return null; final Map<String, Object> old = new HashMap<String, Object>(); for (Map.Entry<String, Object> me : _dynams.entrySet()) { final String nm = me.getKey(); final Object val = me.getValue(); old.put(nm, exec.getAttribute(nm)); if (val != null) exec.setAttribute(nm, val); else exec.removeAttribute(nm); } return old; }
public void init(Execution exec, Execution parent) { if (_enabled) { if (parent == null) { //root execution //always prepare a ThreadLocal SessionMap in Execution attribute Map<Object, Object> map = getSessionMap(); if (map == null) { map = new HashMap<Object, Object>(); setSessionMap(map); //copy to servlet thread's ThreadLocal } exec.setAttribute(HIBERNATE_SESSION_MAP, map); // store in Execution attribute //20060912, henrichen: tricky. Stuff something into session map to //prevent the map from being removed from context ThreadLocal by the //ThreadLocalSessionContext#unbind() when it is empty. map.put(SOMETHING, null); } } }
private static Map<Component, ShadowInfo> getShadowInfos(boolean autoCreate) { Execution exec = Executions.getCurrent(); if (exec == null) return null; Map<Component, ShadowInfo> result = cast((Map) exec.getAttribute(COMPONENT_INFO)); if (result == null && autoCreate) { result = new HashMap<Component, ShadowInfo>(); exec.setAttribute(COMPONENT_INFO, result); } return result; }
private static Map<Component, ComponentInfo> getComponentInfos(boolean autoCreate) { Execution exec = Executions.getCurrent(); if (exec == null) return null; Map<Component, ComponentInfo> result = cast((Map) exec.getAttribute(COMPONENT_INFO)); if (result == null && autoCreate) { result = new HashMap<Component, ComponentInfo>(); exec.setAttribute(COMPONENT_INFO, result); } return result; }
@SuppressWarnings("unchecked") private static Map<String, EntityManager> getEmMap() { Execution current = Executions.getCurrent(); Map map = (Map) current.getAttribute(JPA_EM_MAP); if (map == null) { map = new HashMap(); Executions.getCurrent().setAttribute(JPA_EM_MAP, map); } return map; }
/** * Prepares for rendering a ZHTML tag. After rendering, the caller shall also invoke * {@link #afterRenderTag}. Furthermore, the return value of this method shall be passed as the * <code>param</code> argument of {@link #afterRenderTag}. * * @return the result of this invocation. It shall be passed to the <code>param</code> argument * of {@link #afterRenderTag}. * @see #afterRenderTag */ public static Object beforeRenderTag(Execution exec) { TagRenderContext rc = getTagRenderContext(exec); if (rc != null) return null; // already been called rc = new TagRenderContext(); exec.setAttribute(ATTR_RENDER_CONTEXT, rc); return rc; }
public BindingExecutionInfoCollector getExecutionInfoCollector() { Execution exec = Executions.getCurrent(); if (exec == null) return null; BindingExecutionInfoCollector collector = (BindingExecutionInfoCollector) exec.getAttribute(COLLECTOR_KEY); if (collector == null) { collector = createBindingExecutionInfoCollector(); exec.setAttribute(COLLECTOR_KEY, collector); } return collector; }
public BindingAnnotationInfoChecker getAnnotationInfoChecker() { Execution exec = Executions.getCurrent(); if (exec == null) return null; BindingAnnotationInfoChecker checker = (BindingAnnotationInfoChecker) exec.getAttribute(CHECKER_KEY); if (checker == null) { checker = createDefaultAnnotationInfoChecker(); exec.setAttribute(CHECKER_KEY, checker); } return checker; }
public void doInit(Page page, Map<String, Object> args) throws Exception { //first called doInit, last called doAfterCompose final Execution exec = Executions.getCurrent(); if (exec.getAttribute(RESOLVE_COMPOSITION) == null) { exec.setAttribute(RESOLVE_COMPOSITION, this); } final Component parent = (Component) exec.getAttribute(PARENT); for (Object arg : args.values()) exec.createComponents((String) arg, parent, 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 ""; }
public void render(Page page, Writer out) throws IOException { final Execution exec = Executions.getCurrent(); final String ctl = ExecutionsCtrl.getPageRedrawControl(exec); boolean au = exec.isAsyncUpdate(null); if (!au && (page.isComplete() || "complete".equals(ctl))) { renderComplete(exec, page, out); return; } boolean pageOnly = au; if (!pageOnly) pageOnly = (exec.isIncluded() || "page".equals(ctl)) && !"desktop".equals(ctl); if (pageOnly) renderPage(exec, page, out, au); else { exec.setAttribute(Attributes.PAGE_REDRAW_CONTROL, "complete"); renderComplete(exec, page, out); } }
/** Generates the unavailable message in HTML tags, if any. * @param exec the execution (never null) */ public static String outUnavailable(Execution exec) { if (exec.getAttribute(ATTR_UNAVAILABLE_GENED) == null && !exec.isAsyncUpdate(null)) { exec.setAttribute(ATTR_UNAVAILABLE_GENED, Boolean.TRUE); final Device device = exec.getDesktop().getDevice(); String s = device.getUnavailableMessage(); return s != null ? "<noscript>\n" + s + "\n</noscript>" : ""; } return ""; //nothing to generate }
/** 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 ""; }