List of usage examples for com.vaadin.server VaadinRequest getParameter
public String getParameter(String parameter);
From source file:lv.polarisit.demosidemenu.ValoThemeUI.java
License:Apache License
@Override protected void init(final VaadinRequest request) { if (request.getParameter("test") != null) { testMode = true;/*from w w w . j av a2 s .co m*/ if (browserCantRenderFontsConsistently()) { getPage().getStyles().add(".v-app.v-app.v-app {font-family: Sans-Serif;}"); } } if (getPage().getWebBrowser().isIE() && getPage().getWebBrowser().getBrowserMajorVersion() == 9) { menu.setWidth("320px"); } // Show .v-app-loading valo-menu-badge // try { // Thread.sleep(2000); // } catch (InterruptedException e) { // e.printStackTrace(); // } if (!testMode) { Responsive.makeResponsive(this); } getPage().setTitle("Valo Theme Test"); setContent(root); root.setWidth("100%"); root.addMenu(buildMenu()); navigator = new Navigator(this, viewDisplay); navigator.addView("MessageView", MessageView.class); navigator.addView("MessageView1", MessageView1.class); /* navigator.addView("labels", Labels.class); navigator.addView("buttons-and-links", ButtonsAndLinks.class); navigator.addView("textfields", TextFields.class); navigator.addView("datefields", DateFields.class); navigator.addView("comboboxes", ComboBoxes.class); navigator.addView("checkboxes", CheckBoxes.class); navigator.addView("sliders", Sliders.class); navigator.addView("menubars", MenuBars.class); navigator.addView("panels", Panels.class); navigator.addView("trees", Trees.class); navigator.addView("tables", Tables.class); navigator.addView("splitpanels", SplitPanels.class); navigator.addView("tabs", Tabsheets.class); navigator.addView("accordions", Accordions.class); navigator.addView("colorpickers", ColorPickers.class); navigator.addView("selects", NativeSelects.class); navigator.addView("calendar", CalendarTest.class); navigator.addView("forms", Forms.class); navigator.addView("popupviews", PopupViews.class); navigator.addView("dragging", Dragging.class); */ final String f = Page.getCurrent().getUriFragment(); if (f == null || f.equals("")) { navigator.navigateTo("MessageView"); } //navigator.setErrorView(CommonParts.class); navigator.addViewChangeListener(new ViewChangeListener() { @Override public boolean beforeViewChange(final ViewChangeEvent event) { return true; } @Override public void afterViewChange(final ViewChangeEvent event) { for (final Iterator<Component> it = menuItemsLayout.iterator(); it.hasNext();) { it.next().removeStyleName("selected"); } for (final Entry<String, String> item : menuItems.entrySet()) { if (event.getViewName().equals(item.getKey())) { for (final Iterator<Component> it = menuItemsLayout.iterator(); it.hasNext();) { final Component c = it.next(); if (c.getCaption() != null && c.getCaption().startsWith(item.getValue())) { c.addStyleName("selected"); break; } } break; } } menu.removeStyleName("valo-menu-visible"); } }); }
From source file:net.sf.gazpachoquest.questionnaires.QuestionnairesUI.java
License:Open Source License
@Override public void init(VaadinRequest request) { logger.info("New Vaadin UI created"); String invitation = request.getParameter("invitation"); logger.info("Invitation: {} of sessions : {}", invitation); setSizeFull();/*from ww w .jav a2s .c o m*/ GazpachoViewDisplay viewDisplay = new GazpachoViewDisplay(); setContent(viewDisplay); navigator = new Navigator(this, (ViewDisplay) viewDisplay); navigator.addProvider(viewProvider); navigator.setErrorProvider(new GazpachoErrorViewProvider()); if (isUserSignedIn()) { navigator.navigateTo(QuestionnaireView.NAME); } else { navigator.navigateTo(LoginView.NAME); } }
From source file:org.bubblecloud.ilves.site.DefaultSiteUI.java
License:Apache License
/** * Adds handler for credential posts.//from w w w.j a v a 2 s . co m */ private void addCredentialPostRequestHandler() { // Add handler for credentials post. VaadinSession.getCurrent().addRequestHandler(new RequestHandler() { @Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (!StringUtils.isEmpty(request.getParameter("username")) && !StringUtils.isEmpty(request.getParameter("password")) && getSession() != null && getSession().getSession().getAttribute("user") == null) { final String emailAddress = request.getParameter("username"); final String password = request.getParameter("password"); final EntityManager entityManager = getSite().getSiteContext().getEntityManager(); final Locale locale = getLocale(); final Company company = resolveCompany(entityManager, (VaadinServletRequest) request); final User user = UserDao.getUser(entityManager, company, emailAddress); final String errorKey = LoginService.login(getSite().getSiteContext(), company, user, emailAddress, password); if (errorKey == null) { // Login success final List<Group> groups = UserDao.getUserGroups(entityManager, company, user); DefaultSiteUI.getSecurityProvider().setUser(user, groups); // Check for imminent password expiration. if (user.getPasswordExpirationDate() != null && new DateTime().plusDays(14).toDate() .getTime() > user.getPasswordExpirationDate().getTime()) { final DateTime expirationDate = new DateTime(user.getPasswordExpirationDate()); final DateTime currentDate = new DateTime(); final long daysUntilExpiration = new Duration(currentDate.toDate().getTime(), expirationDate.toDate().getTime()).getStandardDays(); setNotification(DefaultSiteUI.getLocalizationProvider().localize( "message-password-expires-in-days", locale) + ": " + daysUntilExpiration, Notification.Type.WARNING_MESSAGE); } else { setNotification(DefaultSiteUI.getLocalizationProvider().localize( "message-login-success", locale), Notification.Type.TRAY_NOTIFICATION); } } else { // Login failure setNotification(DefaultSiteUI.getLocalizationProvider().localize(errorKey, locale), Notification.Type.WARNING_MESSAGE); } } return false; // No response was written } }); }
From source file:org.freakz.hokan_ng_springboot.bot.SingleSecuredUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { uiServiceMessageHandler.register(this); getPage().setTitle("Hokan"); // Let's register a custom error handler to make the 'access denied' messages a bit friendlier. setErrorHandler(new DefaultErrorHandler() { @Override//from w w w . ja v a2 s . c o m public void error(com.vaadin.server.ErrorEvent event) { if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) { Notification.show("Sorry, you don't have access to do that."); } else { super.error(event); } } }); if (vaadinSecurity.isAuthenticated()) { showMainScreen(); } else { showLoginScreen(request.getParameter("goodbye") != null); } }
From source file:org.opencms.ui.dialogs.CmsEmbeddedDialogsUI.java
License:Open Source License
/** * @see org.opencms.ui.A_CmsUI#init(com.vaadin.server.VaadinRequest) *//* www . j a va2s . c om*/ @Override protected void init(VaadinRequest request) { super.init(request); Throwable t = null; String errorMessage = null; try { OpenCms.getRoleManager().checkRole(getCmsObject(), CmsRole.ELEMENT_AUTHOR); try { String resources = request.getParameter("resources"); List<CmsResource> resourceList; if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(resources)) { resourceList = new ArrayList<CmsResource>(); String[] resIds = resources.split(";"); for (int i = 0; i < resIds.length; i++) { if (CmsUUID.isValidUUID(resIds[i])) { resourceList.add(getCmsObject().readResource(new CmsUUID(resIds[i]), CmsResourceFilter.IGNORE_EXPIRATION)); } } } else { resourceList = Collections.<CmsResource>emptyList(); } String typeParam = request.getParameter("contextType"); ContextType type; String appId = ""; try { type = ContextType.valueOf(typeParam); if (ContextType.containerpageToolbar.equals(type)) { appId = CmsPageEditorConfiguration.APP_ID; } else if (ContextType.sitemapToolbar.equals(type)) { appId = CmsSitemapEditorConfiguration.APP_ID; } } catch (Exception e) { type = ContextType.appToolbar; LOG.error("Could not parse context type parameter " + typeParam); } m_currentContext = new CmsEmbeddedDialogContext(appId, type, resourceList); I_CmsWorkplaceAction action = getAction(request); if (action.isActive(m_currentContext)) { action.executeAction(m_currentContext); } else { errorMessage = CmsVaadinUtils.getMessageText(Messages.GUI_WORKPLACE_ACCESS_DENIED_TITLE_0); } } catch (Throwable e) { t = e; errorMessage = CmsVaadinUtils.getMessageText( org.opencms.ui.dialogs.Messages.ERR_DAILOG_INSTANTIATION_FAILED_1, request.getPathInfo()); } } catch (CmsRoleViolationException ex) { t = ex; errorMessage = CmsVaadinUtils.getMessageText(Messages.GUI_WORKPLACE_ACCESS_DENIED_TITLE_0); } if (errorMessage != null) { CmsErrorDialog.showErrorDialog(errorMessage, t, new Runnable() { public void run() { m_currentContext = new CmsEmbeddedDialogContext("", null, Collections.<CmsResource>emptyList()); m_currentContext.finish(null); } }); } }
From source file:org.opennms.features.vaadin.nodemaps.internal.NodeMapsApplication.java
License:Open Source License
@Override protected void init(final VaadinRequest vaadinRequest) { m_request = vaadinRequest;// w w w .j a va2 s . co m LOG.debug("initializing"); final VaadinApplicationContextImpl context = new VaadinApplicationContextImpl(); final UI currentUI = UI.getCurrent(); context.setSessionId(currentUI.getSession().getSession().getId()); context.setUiId(currentUI.getUIId()); context.setUsername(vaadinRequest.getRemoteUser()); Assert.notNull(m_alarmTable); Assert.notNull(m_nodeTable); final String searchString = vaadinRequest.getParameter("search"); final Integer maxClusterRadius = Integer.getInteger("gwt.maxClusterRadius", 350); LOG.info("Starting search string: {}, max cluster radius: {}", searchString, maxClusterRadius); m_alarmTable.setVaadinApplicationContext(context); final EventProxy eventProxy = new EventProxy() { @Override public <T> void fireEvent(final T eventObject) { LOG.debug("got event: {}", eventObject); if (eventObject instanceof VerticesUpdateEvent) { final VerticesUpdateEvent event = (VerticesUpdateEvent) eventObject; final List<Integer> nodeIds = new ArrayList<Integer>(); for (final VertexRef ref : event.getVertexRefs()) { if ("nodes".equals(ref.getNamespace()) && ref.getId() != null) { nodeIds.add(Integer.valueOf(ref.getId())); } } m_mapWidgetComponent.setSelectedNodes(nodeIds); return; } LOG.warn("Unsure how to deal with event: {}", eventObject); } @Override public <T> void addPossibleEventConsumer(final T possibleEventConsumer) { LOG.debug("(ignoring) add consumer: {}", possibleEventConsumer); /* throw new UnsupportedOperationException("Not yet implemented!"); */ } }; m_alarmTable.setEventProxy(eventProxy); m_nodeTable.setEventProxy(eventProxy); createMapPanel(searchString, maxClusterRadius); createRootLayout(); addRefresher(); // Notify the user if no tileserver url or options are set if (!NodeMapConfiguration.isValid()) { new InvalidConfigurationWindow().open(); } // Schedule refresh of node data m_executor.scheduleWithFixedDelay(() -> m_mapWidgetComponent.refreshNodeData(), 0, 5, TimeUnit.MINUTES); // If we do not shutdown the executor, the scheduler keeps refreshing the node data, even if the // UI may already been detached, resulting at one point in a OutOfMemory. See NMS-8589. vaadinRequest.getService().addSessionDestroyListener(new SessionDestroyListener() { @Override public void sessionDestroy(SessionDestroyEvent event) { m_executor.shutdown(); } }); }
From source file:org.opennms.features.vaadin.pmatrix.engine.UiComponentFactoryImpl.java
License:Open Source License
@Override public Component getUiComponent(VaadinRequest request) { //works with the following URL examples //http://localhost:8080/vaadin-pmatrix/?debug&uiComponent=default //http://localhost:8080/vaadin-pmatrix/?uiComponent=default String componentName = request.getParameter(COMPONENT_REQUEST_PARAMETER); // no component name defined so return null if (componentName == null) return null; //search for specification and construct a component with this name if (pmatrixSpecificationList == null) throw new IllegalStateException("pmatrixSpecificationList cannot be null"); PmatrixSpecification pmatrixSpecification = null; for (PmatrixSpecification pms : pmatrixSpecificationList.getPmatrixSpecificationList()) { if (componentName.equals(pms.getPmatrixName())) { pmatrixSpecification = pms;// w w w. j av a2s . com break; } } // there is no specification for this pmatrix or else we have an unrecognized request so return null if (pmatrixSpecification == null) return null; // otherwise return the constructed table if (LOG.isDebugEnabled()) LOG.debug("constructing a new pmatrixTable for UI with pmatrixName:'" + pmatrixSpecification.getPmatrixName() + "' pmatrixTitle:'" + pmatrixSpecification.getPmatrixTitle() + "'"); if (applicationContext == null) throw new IllegalStateException("applicationContext cannot be null"); PmatrixDataSourceImpl pmatrixDataSource = (PmatrixDataSourceImpl) applicationContext .getBean("pmatrixDataSource"); if (pmatrixDataSource == null) throw new IllegalStateException("cannot get new pmatrixDatasource instance from application context"); pmatrixDataSource.setPmatrixSpecification(pmatrixSpecification); PmatrixTable pmatrixTable = new PmatrixTable(pmatrixDataSource); return pmatrixTable; }
From source file:org.opennms.features.vaadin.surveillanceviews.ui.SurveillanceViewsUI.java
License:Open Source License
/** * {@inheritDoc}/*from w w w.ja va 2 s. c o m*/ */ @Override protected void init(VaadinRequest request) { /** * Force the reload of the configuration */ SurveillanceViewProvider.getInstance().load(); /** * create a layout */ VerticalLayout rootLayout = new VerticalLayout(); rootLayout.setSpacing(true); /** * check query parameters for viewName, dashboard */ String viewName = request.getParameter("viewName"); boolean dashboard = request.getParameter("dashboard") != null && "true".equals(request.getParameter("dashboard")); /** * retrieve the username */ String username = request.getRemoteUser(); /** * now select the right view */ View view; if (viewName == null) { view = m_surveillanceViewService.selectDefaultViewForUsername(username); } else { view = SurveillanceViewProvider.getInstance().getView(viewName); } /** * set the poll interval */ setPollInterval(1000); /** * check for dashboard role */ boolean isDashboardRole = true; SecurityContext context = SecurityContextHolder.getContext(); if ((context != null) && !(context.toString().contains(org.opennms.web.api.Authentication.ROLE_DASHBOARD))) { isDashboardRole = false; } LOG.debug("User {} is in dashboard role? {}", username, isDashboardRole); /** * now construct the surveillance view/dashboard */ rootLayout.addComponent(new SurveillanceView(view, m_surveillanceViewService, dashboard, !isDashboardRole)); setContent(rootLayout); Page.getCurrent().getJavaScript().execute("function receiveMessage(event){\n" + "if(event.origin !== window.location.origin){ return; }\n" + "\n" + "event.source.postMessage( (document.getElementById('surveillance-window').offsetHeight + 17) + 'px', window.location.origin )\n" + "}\n" + "window.addEventListener(\"message\", receiveMessage, false);"); }
From source file:org.ripla.web.util.RiplaRequestHandler.java
License:Open Source License
@Override public boolean handleRequest(final VaadinSession inSession, final VaadinRequest inRequest, final VaadinResponse inResponse) throws IOException { final String lParameter = inRequest.getParameter(Constants.KEY_REQUEST_PARAMETER); if (lParameter != null) { requestParameter = createRequestParameter(lParameter); requestParameter.handleParameters(inSession, inRequest, inResponse); LOG.trace("Handling request parameter '{}'.", lParameter); }//from w ww. j a v a 2 s .c o m return false; }
From source file:org.vaadin.spring.samples.security.managed.SingleSecuredUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle("Vaadin Managed Security Demo"); // Let's register a custom error handler to make the 'access denied' messages a bit friendlier. setErrorHandler(new DefaultErrorHandler() { @Override/* ww w . j a va 2 s. co m*/ public void error(com.vaadin.server.ErrorEvent event) { if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) { Notification.show("Sorry, you don't have access to do that."); } else { super.error(event); } } }); if (vaadinSecurity.isAuthenticated()) { showMainScreen(); } else { showLoginScreen(request.getParameter("goodbye") != null); } }