/** Returns if the ZK specific HTML tags are generated. * @since 5.0.3 */ public static boolean isZkTagsGenerated(Execution exec) { return exec.getAttribute(ATTR_ZK_TAGS_GENERATED) != null; }
public Object getAttribute(Execution exec, String name) { return exec.getAttribute(name); } public void setAttribute(Execution exec, String name, Object value) {
/** Returns the page redraw control. * It first check if a request attribute called * {@link Attributes#PAGE_REDRAW_CONTROL} is defined. * If not, it checks a request parameter called <code>zk.redrawCtrl</code> * is defined. If none of them is defined, null is returned. * @since 5.0.0 */ public static final String getPageRedrawControl(Execution exec) { String ctl = (String) exec.getAttribute(Attributes.PAGE_REDRAW_CONTROL); return ctl != null ? ctl : exec.getParameter("zk.redrawCtrl"); } }
/** Returns the render context, or null if not available. * It is used to render the content that will appear before the content * generated by {@link ContentRenderer}, such as crawlable content. * * @param exec the execution. If null, {@link Executions#getCurrent} * is assumed. */ public static final RenderContext getRenderContext(Execution exec) { if (exec == null) exec = Executions.getCurrent(); return exec != null ? (RenderContext) exec.getAttribute(ATTR_RENDER_CONTEXT) : null; }
/** Returns whether a component can directly generate HTML tags * to the output. * This flag is used by components that can generate the content * directly, such as {@link org.zkoss.zk.ui.HtmlNativeComponent} * @see #setDirectContent */ public static boolean isDirectContent(Execution exec) { if (exec == null) exec = Executions.getCurrent(); return exec != null && exec.getAttribute(ATTR_DIRECT_CONTENT) != null; }
/** * Returns the render context, or null if not available. The render context is available only if * the ZHTML page is rendered directly (rather than via inclusion). * * @param exec * the execution. If null, Executions.getCurrent() is assumed. */ public static TagRenderContext getTagRenderContext(Execution exec) { if (exec == null) exec = Executions.getCurrent(); return exec != null ? (TagRenderContext) exec.getAttribute(ATTR_RENDER_CONTEXT) : null; }
public Object getAttribute(String name, boolean recurse) { return exec().getAttribute(name, recurse); }
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); }
public Object resolveParameter(Annotation anno, Class<?> returnType) { Object val = _execution.getAttribute(((ExecutionParam) anno).value()); return val == null ? null : Classes.coerce(returnType, val); } });
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; }
public boolean init(Component comp, Event evt) { if (_enabled) { //Copy SessionMap stored in Execution attribute into event's ThreadLocal Map<Object, Object> map = cast((Map) Executions.getCurrent().getAttribute(HIBERNATE_SESSION_MAP)); setSessionMap(map); //copy to event thread's ThreadLocal } return true; }
public void afterResume(Component comp, Event evt) { if (_enabled) { //always keep the prepared SessionMap in event's ThreadLocal Map<Object, Object> map = cast((Map) Executions.getCurrent().getAttribute(HIBERNATE_SESSION_MAP)); setSessionMap(map); //copy to event thread's ThreadLocal } }
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; }
private void handleFailedModal(int oldmode, boolean oldvisi) { try { if (Executions.getCurrent().getAttribute("javax.servlet.error.exception") != null) { //handle it specially if it is used for displaying err setMode(HIGHLIGHTED); } else { setMode(oldmode); //restore setVisible(oldvisi); } } catch (Throwable ex) { log.error("Causing another error", ex); } }
/** 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 ""; }
/** 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 ""; }