public void doInit(URL url) { this.url = url; VaadinSession.getCurrent().setErrorHandler(this); init(); }
/** * Called when <em>the first</em> UI of the session is initialized. */ protected void init(Locale requestLocale) { VaadinSession vSession = VaadinSession.getCurrent(); vSession.setAttribute(App.class, this); vSession.setLocale(messageTools.getDefaultLocale()); // set root error handler for all session vSession.setErrorHandler(event -> { try { getExceptionHandlers().handle(event); getAppLog().log(event); } catch (Throwable e) { log.error("Error handling exception\nOriginal exception:\n{}\nException in handlers:\n{}", ExceptionUtils.getStackTrace(event.getThrowable()), ExceptionUtils.getStackTrace(e) ); } }); log.debug("Initializing application"); appLog = new AppLog(webConfig.getAppLogMaxItemsCount(), beanLocator.get(TimeSource.NAME)); connection = createConnection(); exceptionHandlers = new ExceptionHandlers(this, beanLocator); cookies = new AppCookies(); themeConstants = loadTheme(); // get default locale from config Locale targetLocale = resolveLocale(requestLocale); setLocale(targetLocale); }
session.setErrorHandler(errorHandler); page.setTitle(pageTitle());
/** * Make sure you call this from sub-class overrides. The Vaadin Page is not available during the construction of * this class, but is available when this method is invoked. As a result, this method sets the navigator a listener * for URI changes and obtains the browser locale setting for initialising {@link CurrentLocale}. Both of these are * provided by the Vaadin Page. * * @see com.vaadin.ui.UI#init(com.vaadin.server.VaadinRequest) */ @Override protected void init(VaadinRequest request) { VaadinSession session = getSession(); session.setConverterFactory(converterFactory); // page isn't available during injected construction, so we have to do this here Page page = getPage(); page.addUriFragmentChangedListener(navigator); setErrorHandler(errorHandler); session.setErrorHandler(errorHandler); page.setTitle(pageTitle()); // also loads the UserSitemap if not already loaded getKrailNavigator().init(); //layout this UI, which may also create UYI components doLayout(); // now that browser is active, and user sitemap loaded, and UI constructed, set up currentLocale currentLocale.readFromEnvironment(); translator.translate(this); // Navigate to the correct start point String fragment = getPage().getUriFragment(); getKrailNavigator().navigateTo(fragment); }
/** * @see com.vaadin.ui.UI#init(com.vaadin.server.VaadinRequest) */ @Override protected void init(VaadinRequest request) { addStyleName("login-dialog"); LoginParameters params = (LoginParameters)(request.getWrappedSession().getAttribute(INIT_DATA_SESSION_ATTR)); if (params == null) { params = CmsLoginHelper.getLoginParameters(getCmsObject(), (HttpServletRequest)request, true); request.getWrappedSession().setAttribute(CmsLoginUI.INIT_DATA_SESSION_ATTR, params); } VaadinSession.getCurrent().setErrorHandler(new CmsVaadinErrorHandler()); m_controller = new CmsLoginController(m_adminCms, params); m_controller.setUi(this); setLocale(params.getLocale()); m_loginForm = new CmsLoginForm(m_controller, params.getLocale()); m_controller.onInit(); getPage().setTitle( CmsAppWorkplaceUi.WINDOW_TITLE_PREFIX + CmsVaadinUtils.getMessageText(org.opencms.workplace.Messages.GUI_LOGIN_HEADLINE_0)); } }
/** * @see com.vaadin.ui.UI#init(com.vaadin.server.VaadinRequest) */ @Override protected void init(VaadinRequest req) { super.init(req); if (!OpenCms.getRoleManager().hasRole(getCmsObject(), CmsRole.EDITOR)) { Notification.show( CmsVaadinUtils.getMessageText(Messages.GUI_WORKPLACE_ACCESS_DENIED_TITLE_0), CmsVaadinUtils.getMessageText(Messages.GUI_WORKPLACE_ACCESS_DENIED_MESSAGE_0), Type.ERROR_MESSAGE); return; } getSession().setErrorHandler(new CmsVaadinErrorHandler(this)); m_navigationStateManager = new Navigator.UriFragmentManager(getPage()); CmsAppNavigator navigator = new CmsAppNavigator(this, m_navigationStateManager, this); navigator.addProvider(this); setNavigator(navigator); Page.getCurrent().addBrowserWindowResizeListener(this); m_history = new CmsHistoryExtension(getCurrent()); CmsWindowCloseExtension windowClose = new CmsWindowCloseExtension(getCurrent()); windowClose.addWindowCloseListener(this); navigator.addViewChangeListener(this); navigateToFragment(); getReconnectDialogConfiguration().setDialogText( CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_SYSTEM_CONNECTION_LOST_TRYING_RECONNECT_0)); getReconnectDialogConfiguration().setDialogTextGaveUp( CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_SYSTEM_CONNECTION_LOST_GIVING_UP_0)); }