/** Returns the current page. * @since 5.0.10 */ protected Page getPage() { final Execution exec = Executions.getCurrent(); return exec != null ? ((ExecutionCtrl) exec).getCurrentPage() : null; }
/** Returns the component definition of the specified class, or null * if not found. */ /*package*/ static ComponentDefinition getDefinition(Execution exec, Class<? extends Component> cls) { if (exec != null) { final ExecutionCtrl execCtrl = (ExecutionCtrl) exec; final PageDefinition pgdef = execCtrl.getCurrentPageDefinition(); final Page page = execCtrl.getCurrentPage(); final ComponentDefinition compdef = pgdef != null ? pgdef.getComponentDefinition(cls, true) : page != null ? page.getComponentDefinition(cls, true) : null; if (compdef != null && compdef.getLanguageDefinition() != null) return compdef; //already from langdef (not from pgdef) final ComponentDefinition compdef2 = Components.getDefinitionByDeviceType(exec.getDesktop().getDeviceType(), cls); return compdef != null && (compdef2 == null || !Objects.equals(compdef.getImplementationClass(), compdef2.getImplementationClass())) ? compdef : compdef2; //Feature 2816083: use compdef2 if same class } for (String deviceType : LanguageDefinition.getDeviceTypes()) { final ComponentDefinition compdef = Components.getDefinitionByDeviceType(deviceType, cls); if (compdef != null) return compdef; } return null; }
public void setDefinition(String name) { final Execution exec = Executions.getCurrent(); if (exec != null) { final ExecutionCtrl execCtrl = (ExecutionCtrl) exec; final PageDefinition pgdef = execCtrl.getCurrentPageDefinition(); final Page page = execCtrl.getCurrentPage(); ComponentDefinition compdef = pgdef != null ? pgdef.getComponentDefinition(name, true) : page != null ? page.getComponentDefinition(name, true) : null; if (compdef == null) compdef = Impls.getDefinitionByDeviceType(this, exec.getDesktop().getDeviceType(), name); if (compdef != null) { setDefinition(compdef); return; } } else { for (String deviceType : LanguageDefinition.getDeviceTypes()) { final ComponentDefinition compdef = Impls.getDefinitionByDeviceType(this, deviceType, name); if (compdef != null) { setDefinition(compdef); return; } } } throw new ComponentNotFoundException(name + " not found"); }
/** Returns the current scope. * The current scope is the event target's scope if this thread * is processing an event ({@link org.zkoss.zk.ui.event.Event#getTarget}. * Otherwise, the scope of the page specified is assumed. * * <p>This method is used only to implement {@link org.zkoss.zk.scripting.Interpreter}. * You rarely need to access it other than implementing an interpreter. * * @param page the page. It is used if {@link #beforeInterpret} * is not called before. If null, the current page ({@link ExecutionCtrl#getCurrentPage} * is assumed. */ public static final Scope getCurrent(Page page) { final List<Scope> nss = _scopes.get(); final Scope scope = nss != null && !nss.isEmpty() ? nss.get(0) : null; if (scope != null) return scope; if (page == null) { final Execution exec = Executions.getCurrent(); if (exec != null) page = ((ExecutionCtrl) exec).getCurrentPage(); } return page; }
page = ppg; else if (page == null) page = execCtrl.getCurrentPage(); final Page prevpg = execCtrl.getCurrentPage(); if (page != null && page != prevpg) execCtrl.setCurrentPage(page);
/** Returns the current page. */ protected Page getPage() { if (_self != null) { final Page page = _self.getPage(); if (page != null) return page; } final Execution exec = Executions.getCurrent(); return exec != null ? ((ExecutionCtrl) exec).getCurrentPage() : null; }
final Page old = execCtrl.getCurrentPage(); final PageDefinition olddef = execCtrl.getCurrentPageDefinition(); execCtrl.setCurrentPage(page);
/** Returns the page of the give component, or the current page if the * component is null or it doesn't belong to any page. * The current page is retrieved by {@link ExecutionCtrl#getCurrentPage} * or the current execution. This method returns null if no execution * or no current page at all. * @param comp the component to retrieve the page. Ignored if null. * @since 6.0.0 */ public static Page getCurrentPage(Component comp) { if (comp != null) { Page page = comp.getPage(); if (page != null) return page; } final Execution exec = Executions.getCurrent(); return exec != null ? ((ExecutionCtrl) exec).getCurrentPage() : null; }
final Execution exec = Executions.getCurrent(); final Desktop desktop = exec.getDesktop(); Page page = ((ExecutionCtrl) exec).getCurrentPage(); if (page == null) { page = desktop.getFirstPage();
/** Returns the function mapper, or null if not available. * * <p>Default: returns the function mapper passed thru * {@link #SimpleEvaluator}. * * @param ref the object,either page, component, or null. * It is passed to {@link #evaluate} */ public FunctionMapper getFunctionMapper(Object ref) { if (ref instanceof Component) ref = ((Component) ref).getPage(); if (ref == null) { ExecutionCtrl execCtrl = ExecutionsCtrl.getCurrentCtrl(); if (execCtrl != null) ref = execCtrl.getCurrentPage(); } return DualFunctionMapper.combine(ref instanceof Page ? ((Page) ref).getFunctionMapper() : null, _mapper); }
/** * Displays a message. * @param msg the message to show * @param type available types are "info", "warning", "error" * @param ref the referenced component, null to be based on browser window * @param x the horizontal position of the notification, aligned at top-left (in pixel) * @param y the vertical position of the notification, aligned at top-left (in pixel) * @param duration the duration of notification in millisecond. If zero or * negative the notification does not dismiss until user left-clicks outside * of the notification box. * @param closable whether to close notification manually or not. If true there will be a * close button on notification message and won't close until user click the button * or duration time up, default false. * @since 6.5.0 */ public static final void showNotification(String msg, String type, Component ref, int x, int y, int duration, boolean closable) { Execution exec = Executions.getCurrent(); Page page = ref != null ? ref.getPage() : null; if (page == null && exec instanceof ExecutionCtrl) page = ((ExecutionCtrl) exec).getCurrentPage(); if (type == null) type = NOTIFICATION_TYPE_INFO; response(new AuNotification(msg, type, page, ref, x, y, duration, closable)); }
Page page = ref != null ? ref.getPage() : null; if (page == null && exec instanceof ExecutionCtrl) page = ((ExecutionCtrl) exec).getCurrentPage(); if (type == null) type = NOTIFICATION_TYPE_INFO;
if (o != null) return o; final Page page = ((ExecutionCtrl) _exec).getCurrentPage(); return page != null ? page.getXelVariable(ctx, base, onm, true) : null; if (self instanceof Page) return ((Page) self).getAttributes(); final Page page = ((ExecutionCtrl) _exec).getCurrentPage(); return page != null ? page.getAttributes() : Collections.EMPTY_MAP; if (self instanceof Page) return self; return ((ExecutionCtrl) _exec).getCurrentPage(); page = (Page) self; } else { page = ((ExecutionCtrl) _exec).getCurrentPage();
/** Evaluates the value to an Object. * Note: it does NOT call {@link #isEffective} and it doesn't coerce * the result (i.e., Object.class is assumed). */ public Object getValue(Component comp) { if (_value != null) return _value.getValue(_evalr, comp); Desktop desktop = comp.getDesktop(); Page page; if (desktop == null) { Execution exec = Executions.getCurrent(); if (exec == null) throw new IllegalStateException("Not attached, nor execution"); desktop = exec.getDesktop(); page = ((ExecutionCtrl) exec).getCurrentPage(); } else { page = comp.getPage(); } return ((WebAppCtrl) desktop.getWebApp()).getUiEngine().getNativeContent(comp, _navval.getChildren(), ((Native) _navval.newInstance(page, comp)).getHelper()); }
richlet.service(((ExecutionCtrl) exec).getCurrentPage()); else exec.createComponents(location, null, null);
if (!desktop.getWebApp().getConfiguration().isEventThreadEnabled()) { final ExecutionCtrl execCtrl = (ExecutionCtrl) exec; final Page page = execCtrl.getCurrentPage(); final EventProcessor proc = new EventProcessor(desktop, comp, event); proc.setup();
final boolean fakepg = page == null; if (fakepg) { prevPage = execCtrl.getCurrentPage(); page = new VolatilePage(prevPage); ((PageCtrl) page).preInit();