public Component getFellowIfAny(String compId, boolean recurse) { if (!recurse) return getFellowIfAny(compId); for (IdSpace idspace = getSpaceOwner(); idspace != null;) { Component f = idspace.getFellowIfAny(compId); if (f != null) return f; idspace = Components.getParentIdSpace(idspace); } return null; }
/** 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"); }
private static WebApp getWebApp() { WebApp app = null; final Execution exec = Executions.getCurrent(); if (exec != null) { final Desktop desktop = exec.getDesktop(); if (desktop != null) { app = desktop.getWebApp(); } } return app; }
/** * Get the spring application context. */ public static ApplicationContext getApplicationContext() { Execution exec = Executions.getCurrent(); if (exec == null) { throw new UiException("SpringUtil can be called only under ZK environment!"); } return WebApplicationContextUtils .getRequiredWebApplicationContext(exec.getDesktop().getWebApp().getServletContext()); }
private static Desktop getDesktop(Component comp) { final Desktop dt = comp.getDesktop(); if (dt != null) return dt; final Execution exec = Executions.getCurrent(); return exec != null ? exec.getDesktop() : null; }
private static void addToIdSpacesDown(Component comp, IdSpace owner) { if (!(comp instanceof NonFellow) && !isAutoId(comp.getId())) addFellow(comp, owner); if (!(comp instanceof IdSpace)) for (AbstractComponent ac = (AbstractComponent) comp.getFirstChild(); ac != null; ac = ac._next) addToIdSpacesDown(ac, owner); //recursive ((AbstractComponent) comp).notifyIdSpaceChanged(owner); }
/** 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; }
/** 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); }
/** A shortcut of Executions.getCurrent().include(page). * * @see Execution#include(java.io.Writer,String,Map,int) * @see Execution#include(String) */ public static void include(String page) throws IOException { getCurrent().include(page); }
public void cleanup(Execution exec, Execution parent, List errs) throws Exception { Session sess = exec.getSession(); //enforce GAE to write session //enforce Weblogic to sync session if (sess != null) sess.setAttribute(Attributes.ZK_SESSION, sess.getAttribute(Attributes.ZK_SESSION)); }
public String getRemoteAddr() { Execution execution = Executions.getCurrent(); if (execution != null) return execution.getRemoteAddr(); return null; }
public String getRemoteHost() { Execution execution = Executions.getCurrent(); if (execution != null) return execution.getRemoteHost(); return null; }
public String getLocalAddr() { Execution execution = Executions.getCurrent(); if (execution != null) return execution.getLocalAddr(); return null; }
/** Returns the evaluator of the current execution. * It is a shortcut of getEvaluator(comp != null ? comp.getPage(): null) * * @param comp the component to retrieve the page for the evaluator * @param expfcls the implementation of {@link ExpressionFactory}, * or null to use the default ({@link org.zkoss.zk.ui.util.Configuration#getExpressionFactoryClass}. * @since 3.0.0 */ public static final Evaluator getEvaluator(Component comp, Class<? extends ExpressionFactory> expfcls) { return getCurrent().getEvaluator(comp, expfcls); }
protected void removeFromParent() { if (_parent == null) { throw new UiException("The parent shadow cannot be null."); } _parent.removeChild(this); }
private static IdSpace getSpaceOwnerOfParent(Component comp) { final Component parent = comp.getParent(); return parent != null ? spaceOwnerNoVirtual(parent) : //ignore virtual IdSpace comp.getPage(); }
private static void removeFellow(Component comp, IdSpace owner) { if (owner instanceof Component) ((AbstractComponent) owner).unbindFromIdSpace(comp.getId()); else if (owner instanceof Page) ((AbstractPage) owner).removeFellow(comp); if (owner == null && comp instanceof ShadowElement) removeFromShadowIdMap(comp); }
/** Returns the ZK version, such as "1.1.0" and "2.0.0". * @since 6.0.3 */ public static String getVersion() { return WebApps.getCurrent().getVersion(); }
private static void addFellow(Component comp, IdSpace owner) { if (owner instanceof Component) ((AbstractComponent) owner).bindToIdSpace(comp); else if (owner instanceof Page) ((AbstractPage) owner).addFellow(comp); if (owner == null && comp instanceof ShadowElement) addToShadowIdMap(comp); }
/** 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; }