/** * Returns true if the component has been rendered on the browser. A component is considered * rendered if it belongs to a rendered page. * * @return True if the component has been rendered on the browser. */ public boolean isRendered() { return page != null && page.getId() != null; }
/** * Returns an instance of the design context menu. This is a singleton with the page scope and * is cached once created. * * @return The design context menu for the active page. */ public static DesignContextMenu getInstance() { Page page = ExecutionContext.getPage(); DesignContextMenu contextMenu = page.getAttribute(DesignConstants.ATTR_DESIGN_MENU, DesignContextMenu.class); if (contextMenu == null) { contextMenu = create(); page.setAttribute(DesignConstants.ATTR_DESIGN_MENU, contextMenu); } return contextMenu; }
/** * Creates a callback registry for the specified page using the specified eviction interval. * * @param page The owning page. * @param evictionInterval The time in milliseconds after which an entry will be evicted. */ public CallbackRegistry(Page page, long evictionInterval) { this.evictionInterval = evictionInterval; page.addEventListener(CallbackEvent.class, callbackListener); }
/** * Returns the help viewer mode for the specified page. * * @param page The page to check. If null, the global setting is returned. * @return The help viewer mode. */ public static HelpViewerMode getViewerMode(Page page) { return page == null || !page.hasAttribute(EMBEDDED_ATTRIB) ? defaultMode : (HelpViewerMode) page.getAttribute(EMBEDDED_ATTRIB); }
/** * Queues a logout request. */ private void requestLogout() { boolean loggingOut = page.hasAttribute(ATTR_LOGGING_OUT); if (!loggingOut) { page.setAttribute(ATTR_LOGGING_OUT, true); logout(); } else { log.debug("Logout already underway"); } }
/** * Remove all listeners upon close. */ @EventHandler("close") private void onClose() { Page page = window.getPage(); page.removeEventListener("register unregister", layoutListener); page.removeAttribute(DIALOG); page.setAttribute(ATTR_BRING_TO_FRONT, bringToFront); clipboard.removeListener(window); } }
private static void initPage(Page page, ApplicationContext ctx) { page.setAttribute(APP_CONTEXT_ATTRIB, ctx); } }
String proxyId = page.getQueryParam("proxy"); boolean proxied = proxyId != null; mode = proxied ? HelpViewerMode.POPUP : HelpViewerMode.EMBEDDED; page.setTitle("Help"); InvocationRequestQueue proxyQueue = InvocationRequestQueueRegistry.getInstance().get("help" + proxyId); close(); } else { requestQueue = new InvocationRequestQueue("help" + page.getId(), page, this, HelpUtil.closeRequest); proxyQueue.sendRequest("setRemoteQueue", requestQueue);
/** * Registers/unregisters a component newly attached to this page. * * @param component Component to register/unregister. * @param register If true, register the component. If false, unregister it. */ /*package*/ void registerComponent(BaseComponent component, boolean register) { if (getId() == null) { return; } String id = component.getId(); if (id == null) { id = nextComponentId(); component._setId(id); } if (register) { ids.put(id, component); } else { ids.remove(id); } Event event = new Event(register ? "register" : "unregister", this, component); fireEvent(event); }
/** * Invoked by the background thread when it has completed the target operation, even if aborted. * This schedules a notification on the desktop's event thread where the requester is notified * of the completion. */ protected void done() { try { page.getEventQueue().queue(event); } catch (Exception e) { log.error(e); } }
@Override public void afterInitialized(BaseComponent comp) { window = (Window) comp; window.setCloseAction(CloseAction.HIDE); comp.setAttribute("controller", this); bringToFront = comp.getPage().getAttribute(ATTR_BRING_TO_FRONT, true); layoutChangedEvent = new LayoutChangedEvent(comp, null); contextMenu.setListener(comp); clipboard.addListener(comp); comp.getPage().addEventListener("register unregister", layoutListener); }
/** * Returns the application context associated with the given page. * * @param page Page instance. * @return Application context associated with the page. */ public static XmlWebApplicationContext getAppContext(Page page) { return page == null ? null : (XmlWebApplicationContext) page.getAttribute(APP_CONTEXT_ATTRIB); }
@Override public void handleRequest(ClientRequest request) { Page page = request.getPage(); PageDefinition pageDefinition = PageDefinitionCache.getInstance().get(page.getSrc()); Synchronizer synchronizer = request.getSession().getSynchronizer(); synchronizer.startQueueing(); Page._init(page, request, synchronizer); Sessions.getInstance().notifyLifecycleListeners(request.getSession(), true); try { page.invoke("beforeInitialize", clientOptionMap); pageDefinition.materialize(page); page.invoke("afterInitialize"); page.fireEvent("afterInitialize"); } catch (Exception e) { synchronizer.clear(); throw new SessionInitException(e); } finally { synchronizer.stopQueueing(); } }
@Override public void onSessionCreate(Session session) { session.getPage().addEventListener("afterInitialize", (event) -> { ReportHeaderRegistry rhr = getInstance(); Namespace headerRoot = new Namespace(); headerRoot.addStyle("display", "none"); headerRoot.setName("report_headers"); for (Entry<String, String> entry : rhr.map.entrySet()) { String key = entry.getKey(); String url = entry.getValue(); try { Namespace root = new Namespace(); root.setName(key); PageUtil.createPage(url, root); root.setParent(headerRoot); } catch (Exception e) { log.error("Error loading report header " + key, e); } } session.getPage().addChild(headerRoot); }); }
@Override public void afterInitialized(BaseComponent root) { super.afterInitialized(root); page = root.getPage(); session = page.getSession(); noAutoLock = page.getAttribute(ATTR_NO_AUTO_LOCK, false); timeoutWindow = (BaseUIComponent) root; getEventManager().subscribe(SessionControl.EVENT_ROOT, applicationControlListener); IUser user = securityService.getAuthenticatedUser(); lblLocked.setLabel(user == null ? null : Mode.BASELINE.getLabel(TIMEOUT_EXPIRATION, user.getFullName() + "@" + user.getSecurityDomain().getName())); setMode(Mode.BASELINE); session.addSessionListener(sessionListener); }
/** * Returns the original request url from the execution context. * * @return The request url of the browser document. */ public static String getRequestUrl() { return ExecutionContext.getPage().getBrowserInfo("requestURL"); }
/** * Override to implement any special controller initialization logic. */ protected void initializeController() { log.trace("Initializing Controller"); if (lblMessage != null) { lblMessage.addStyle("text-align", "center"); } Style style = new Style(); style.setSrc(CWFUtil.getResourcePath(AbstractServiceController.class, 1) + "common.css"); root.getPage().addChild(style); }
public String getAppProperty(String queryParam, String propName) { String result = getPage().getQueryParam(queryParam); return result == null ? PropertyUtil.getValue(propName) : result; }
Page._init(page, clientRequest, session.getSynchronizer()); page = initPage(page);