/** * 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; }
/** Sends an AU response ({@link AuResponse}) to the client. * It is the same as <code>response(response.getOverrideKey(), response)</code>. * * @since 3.0.0 */ public static final void response(AuResponse response) { Executions.getCurrent().addAuResponse(response); }
/** Queues the give event for the specified target to this execution. * The target could be different from {@link Event#getTarget}. * @param realTarget the target component that will receive the event. * If null, it means broadcast, i.e., all root components will receive * this event. * <br/>Notice that postEvent(n, event) is the same as postEvent(n, event.getTarget(), event), * but different from postEvent(n, 0, event). * @since 5.0.7 */ public static final void postEvent(Component realTarget, Event event) { Executions.getCurrent().postEvent(0, realTarget, event); }
@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; }
/** Converts the specified URI to absolute if necessary. * Refer to {@link org.zkoss.zk.ui.Execution#toAbsoluteURI}. * * @param skipInclude whether not to convert to an absolute URI if * the current page is included by another page. * When use the include directive, skipInclude shall be true. */ public static String toAbsoluteURI(String uri, boolean skipInclude) { return Executions.getCurrent().toAbsoluteURI(uri, skipInclude); }
public void close() { _closed = true; final Execution exec = Executions.getCurrent(); if (exec != null) close(exec.getDesktop()); //queues of other desktops will be closed in EQService }
public ExecutionCarryOver(Desktop desktop) { _exec = Executions.getCurrent(); if (_exec == null || _exec.getDesktop() != desktop) throw new IllegalStateException("Wrong execution: " + _exec); _locale = Locales.getCurrent(); _timeZone = TimeZones.getCurrent(); }
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; }
private static final UiEngine getUiEngine() { final Execution exec = getCurrent(); if (exec == null) throw new IllegalStateException("This method can be called only under an event listener"); return ((WebAppCtrl) exec.getDesktop().getWebApp()).getUiEngine(); } }
public void preInit() { if (_desktop != null) throw new IllegalStateException("init twice"); final Execution exec = Executions.getCurrent(); _desktop = exec.getDesktop(); if (_desktop == null) throw new IllegalArgumentException("null desktop"); _desktop.getWebApp().getConfiguration().init(this); }
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; }
/*package*/ boolean isNativeScrollbar() { ServletRequest request = (ServletRequest) Executions.getCurrent().getNativeRequest(); // B70-ZK-2489: Set org.zkoss.zul.nativebar's default to false when using a mobile device if (Servlets.isBrowser(request, "ie8-")) { return true; } else { return Utils.testAttribute(this, "org.zkoss.zul.nativebar", true, true); } }
/** Checks whether it is OK to detach the specified page. * @param page the page to detach (never null). */ private static void checkDetach(Page page) { final Execution exec = Executions.getCurrent(); if (exec == null) throw new UiException("You cannot access a desktop other than an event listener"); if (page.getDesktop() != exec.getDesktop()) throw new UiException("You cannot access components belong to other desktop"); }
public void attributeRemoved(ServletRequestAttributeEvent evt) { final String name = evt.getName(); if (!shallIgnore(name)) { final Execution exec = Executions.getCurrent(); if (exec instanceof ExecutionImpl && evt.getServletRequest().equals(exec.getNativeRequest())) ((ExecutionImpl) exec).getScopeListeners().notifyRemoved(name); } }
/** 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); }
private static final CCInfo beforeCC(WebApp wapp) { Execution exec = Executions.getCurrent(); if (exec != null) return new CCInfo(exec, false); ((WebAppCtrl) wapp).getUiEngine().activate(exec = CCExecution.newInstance(wapp)); return new CCInfo(exec, true); }
private boolean isEventThreadEnabled(boolean attachedRequired) { Desktop desktop = getDesktop(); if (desktop == null) { if (attachedRequired) throw new SuspendNotAllowedException("Not attached, " + this); final Execution exec = Executions.getCurrent(); if (exec == null || (desktop = exec.getDesktop()) == null) return true; //assume enabled (safer) } return desktop.getWebApp().getConfiguration().isEventThreadEnabled(); }
@Override public void onEvent(Event event) throws Exception { // TODO Auto-generated method stub Component c = event.getTarget(); currentSelectedItem = (WonderbarItem) c.getAttribute(OBJECT_FOR_SELECT); currentSelectedText = (String) c.getAttribute(STRING_FOR_SELECT); Event fevent = new Event("onSelectFromBandbox", TestMenu.this); Executions.getCurrent().postEvent(fevent); }