/** Ensure the use of component is correct. */ private void checkDesktop(Component comp) { final Desktop dt = comp.getDesktop(); if (dt != null && dt != _exec.getDesktop()) throw new IllegalStateException( "Access denied: component, " + comp + ", belongs to another desktop: " + dt); }
public String getUpdateURI(String pathInfo) { final String uri; if (pathInfo == null || pathInfo.length() == 0) { uri = _updateURI; } else { if (pathInfo.charAt(0) != '/') pathInfo = '/' + pathInfo; uri = _updateURI + pathInfo; } return _exec.encodeURL(uri); }
/** Constructor. * * @param exec the current execution, never null * @param locator the locator used to locate taglib and other resources. * If null, {@link #getWebApp} is used. */ public RequestInfoImpl(Execution exec, Locator locator) { this(exec.getDesktop(), exec.getNativeRequest(), locator); }
/** 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"); } }
/** 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; }
/** 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 }
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 void removeAttribute(Execution exec, String name) { ((ServletRequest)exec.getNativeRequest()).removeAttribute(name); //can't access removeAttribute directly, since signature of ZK 5 changed } public Inline newInline(String txt){
/** 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 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); }
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; }
exec.setAttribute(ZkEventExceptionFilter.EXCEPTION, ex); exec.setAttribute(ZkEventExceptionFilter.COMPONENT, comp); exec.setAttribute(ZkEventExceptionFilter.EVENT, evt); exec.setAttribute(ZkAuthenticationProcessingFilter.CURRENT_EVENT, evt); ServletRequest request = (ServletRequest) exec.getNativeRequest(); ServletResponse response = (ServletResponse) exec.getNativeResponse(); ServletResponse resp = BufferedResponse.getInstance(response, new NullWriter()); try {
public void doAfterCompose(Page page, Component[] comps) throws Exception { final Execution exec = Executions.getCurrent(); //resolve only once in the last page if (exec.getAttribute(RESOLVE_COMPOSITION) != this) { return; } exec.removeAttribute(RESOLVE_COMPOSITION); // resolve insert components final Map<String, Component> insertMap = new HashMap<String, Component>(); //(insert name, insert component) final Component parent = (Component) exec.getAttribute(PARENT); final Collection<Component> roots = (parent == null ? page.getRoots() : parent.getChildren()); resolveInsertComponents(roots, insertMap); //B65-ZK-2072: Resolves define components recursively. resolveDefineComponents(roots, insertMap); }
public boolean remove(String name, String scope) { final Execution exec = Executions.getCurrent(); if (exec == null) throw new IllegalStateException("Not in an execution"); if (EventQueues.DESKTOP.equals(scope)) return remove0(name, exec.getDesktop()); if (EventQueues.APPLICATION.equals(scope)) return remove0(name, exec.getDesktop().getWebApp()); if (EventQueues.SESSION.equals(scope)) return remove0(name, exec.getSession()); return false; }
// check if request needs to be sent back if (!isValidRequest()) { // get the current execution context Execution exec = Executions.getCurrent(); // retrieve HTTP request, response objects HttpServletRequest request = (HttpServletRequest) exec.getNativeRequest(); HttpServletResponse response = (HttpServletResponse) exec.getNativeResponse(); // get the referring URL from HTTP header String referrer = request.getHeader("Referer"); /* don't need to use this unless doing a forward (server-side) if (referrer != null) { URL ref = new URL(referrer); referrer = ref.getPath().substring(request.getContextPath().length()); } else { referrer = "/index.jsp"; // home page } */ // HTTP 301 redirect (client-side); encoding ensures URL rewriting if required response.sendRedirect(response.encodeRedirectURL(referrer)); exec.setVoided(true); // no need to create UI; about to redirect }
Desktop desktop = exec.getDesktop(); String command = exec.getParameter("cmd_0"); if ("dummy".equals(command)) { return;
public void onEvent(Event evt) throws Exception { for (int j = _targets.length; --j >= 0;) _targets[j].removeEventListener(_evtnms[j], this); //one shot only final Execution exec = Executions.getCurrent(); execCreate0( new CreateInfo(((WebAppCtrl) exec.getDesktop().getWebApp()).getUiFactory(), exec, _comp.getPage(), null), //technically sys composer can be used but we don't (to simplify it) _compInfo, _comp, null); if (_uri != null) { final String uri = (String) Evaluators.evaluate(_compInfo.getEvaluator(), _comp, _uri, String.class); if (uri != null) exec.createComponents(uri, _comp, null); } Events.sendEvent(new FulfillEvent(Events.ON_FULFILL, _comp, evt)); //Use sendEvent so onFulfill will be processed before //the event triggers the fulfill (i.e., evt) }
public Component[] createComponents(String uri, Component parent, Component insertBefore, VariableResolver resolver, Map<?, ?> arg) { return exec().createComponents(uri, parent, insertBefore, resolver, arg); }
/** * Sets the theme name using the current theme resolution strategy * Default strategy is to use cookies * * @param exe Execution * @param themeName the new intended theme name */ public static void setTheme(Execution exe, String themeName) { ThemeResolver themeResolver = ThemeFns.getThemeResolver(); themeResolver.setTheme((HttpServletRequest) exe.getNativeRequest(), (HttpServletResponse) exe.getNativeResponse(), themeName); }
/** 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; }