private static void initPage(Page page, ApplicationContext ctx) { page.setAttribute(APP_CONTEXT_ATTRIB, ctx); } }
/** * 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"); } }
/** * Sets the active instance of the CareWeb shell. An exception is raised if an active instance * has already been set. * * @param shell Shell to become the active instance. */ protected static void setShell(CareWebShell shell) { if (getShell() != null) { throw new RuntimeException("A CareWeb shell instance has already been registered."); } ExecutionContext.getPage().setAttribute(Constants.SHELL_INSTANCE, shell); }
/** * Sets the help viewer mode for the specified page. If different from the previous mode and a * viewer for this page exists, the viewer will be removed and recreated on the next request. * * @param page The target page. * @param mode The help viewer mode. */ public static void setViewerMode(Page page, HelpViewerMode mode) { if (getViewerMode(page) != mode) { removeViewer(page, true); } page.setAttribute(EMBEDDED_ATTRIB, mode); }
/** * 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; }
/** * Returns an instance of the layout manager. If the layout manager is open, returns that * instance. If not and autoCreate is true, creates a new one. * * @param autoCreate If true and dialog does not exist, it is created. * @return The layout manager. */ private static Window getInstance(boolean autoCreate) { Page page = ExecutionContext.getPage(); Window dlg = page.getAttribute(DIALOG, Window.class); if (autoCreate && dlg == null) { dlg = DialogUtil.popup(DIALOG, true, true, false); page.setAttribute(DIALOG, dlg); } return dlg; }
/** * Creates an instance of the help viewer, associating it with the specified page. * * @param page Page owning the help viewer instance. * @return The newly created help viewer. */ private static IHelpViewer createViewer(Page page) { IHelpViewer viewer; if (getViewerMode(page) == HelpViewerMode.POPUP) { viewer = new HelpViewerProxy(page); } else { BaseComponent root = PageUtil.createPage(VIEWER_URL, page).get(0); viewer = (IHelpViewer) root.getAttribute("controller"); } page.setAttribute(VIEWER_ATTRIB, viewer); return viewer; }
/** * Returns a reference to the registry for global or local actions. * * @param global If true, return the global registry; if false, the local registry. * @return An action registry. */ private static ActionRegistry getRegistry(boolean global) { if (global) { return instance; } Page page = ExecutionContext.getPage(); ActionRegistry registry = (ActionRegistry) page.getAttribute(ATTR_LOCAL_REGISTRY); if (registry == null) { page.setAttribute(ATTR_LOCAL_REGISTRY, registry = new ActionRegistry()); } return registry; }
/** * 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); } }
page.setAttribute(AppContextFinder.APP_CONTEXT_ATTRIB, ctx); ServletContext sc = ExecutionContext.getSession().getServletContext(); ctx.setDisplayName("Child XmlWebApplicationContext " + page);