com.vaadin.server.VaadinRequest Java Examples
The following examples show how to use
com.vaadin.server.VaadinRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RDFUnitDemo.java From RDFUnit with Apache License 2.0 | 6 votes |
private String getClientIpAddr(VaadinRequest request) { String ip = request.getHeader("X-Forwarded-For"); if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("Proxy-Client-IP"); } if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("WL-Proxy-Client-IP"); } if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("HTTP_CLIENT_IP"); } if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("HTTP_X_FORWARDED_FOR"); } if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getRemoteAddr(); } return ip; }
Example #2
Source File: VertxVaadinService.java From vertx-vaadin with MIT License | 6 votes |
@Override public String getMainDivId(VaadinSession session, VaadinRequest request, Class<? extends UI> uiClass) { String appId = request.getPathInfo(); if (appId == null || "".equals(appId) || "/".equals(appId)) { appId = "ROOT"; } appId = appId.replaceAll("[^a-zA-Z0-9]", ""); // Add hashCode to the end, so that it is still (sort of) // predictable, but indicates that it should not be used in CSS // and // such: int hashCode = appId.hashCode(); if (hashCode < 0) { hashCode = -hashCode; } appId = appId + "-" + hashCode; return appId; }
Example #3
Source File: VertxVaadinService.java From vertx-vaadin with MIT License | 6 votes |
@Override public String getStaticFileLocation(VaadinRequest request) { String staticFileLocation; // if property is defined in configurations, use that staticFileLocation = getDeploymentConfiguration().getResourcesPath(); if (staticFileLocation != null) { return staticFileLocation; } VertxVaadinRequest vertxRequest = (VertxVaadinRequest) request; String requestedPath = vertxRequest.getRequest().path() .substring( Optional.ofNullable(vertxRequest.getRoutingContext().mountPoint()) .map(String::length).orElse(0) ); return VaadinServletService.getCancelingRelativePath(requestedPath); }
Example #4
Source File: LinkHandler.java From cuba with Apache License 2.0 | 6 votes |
/** * Called to handle the link. */ public void handle() { try { ExternalLinkContext linkContext = new ExternalLinkContext(requestParams, action, app); for (LinkHandlerProcessor processor : processors) { if (processor.canHandle(linkContext)) { processor.handle(linkContext); break; } } } finally { VaadinRequest request = VaadinService.getCurrentRequest(); WrappedSession wrappedSession = request.getWrappedSession(); wrappedSession.removeAttribute(AppUI.LAST_REQUEST_PARAMS_ATTR); wrappedSession.removeAttribute(AppUI.LAST_REQUEST_ACTION_ATTR); } }
Example #5
Source File: MyUI.java From framework-spring-tutorial with Apache License 2.0 | 6 votes |
@Override protected void init(VaadinRequest request) { final VerticalLayout root = new VerticalLayout(); root.setSizeFull(); setContent(root); final CssLayout navigationBar = new CssLayout(); navigationBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); navigationBar.addComponent(createNavigationButton("UI Scoped View", UIScopedView.VIEW_NAME)); navigationBar.addComponent(createNavigationButton("View Scoped View", ViewScopedView.VIEW_NAME)); root.addComponent(navigationBar); springViewDisplay = new Panel(); springViewDisplay.setSizeFull(); root.addComponent(springViewDisplay); root.setExpandRatio(springViewDisplay, 1.0f); }
Example #6
Source File: Java8LocaleNegotiationStrategy.java From viritin with Apache License 2.0 | 6 votes |
@Override public Locale negotiate(List<Locale> supportedLocales, VaadinRequest vaadinRequest) { String languages = vaadinRequest.getHeader("Accept-Language"); try { // Use reflection here, so the code compiles with jdk 1.7 Class<?> languageRange = Class .forName("java.util.Locale$LanguageRange"); Method parse = languageRange.getMethod("parse", String.class); Object priorityList = parse.invoke(null, languages); Method lookup = Locale.class.getMethod("lookup", List.class, Collection.class); return (Locale) lookup.invoke(null, priorityList, supportedLocales); } catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) { throw new RuntimeException( "Java8LocaleNegotiontionStrategy need java 1.8 or newer.", e); } }
Example #7
Source File: Issue309PojoForm.java From viritin with Apache License 2.0 | 6 votes |
@Override protected void init(VaadinRequest request) { AbstractForm<Pojo> form = new AbstractForm<Pojo>(Pojo.class) { private static final long serialVersionUID = 1251886098275380006L; IntegerField myInteger = new IntegerField("My Integer"); @Override protected Component createContent() { FormLayout layout = new FormLayout(myInteger, getToolbar()); return layout; } }; form.setResetHandler((Pojo entity) -> { form.setEntity(null); }); form.setEntity(new Pojo()); setContent(form); }
Example #8
Source File: TimesheetUI.java From vaadinator with Apache License 2.0 | 6 votes |
@Override protected void init(VaadinRequest request) { // TODO: remove test-entry into contet context.put(CONTEXT_LOGIN_USER, "sebastian"); // create NavigationManager m = new NavigationManager(); m.setMaintainBreadcrumb(true); TimesheetChangePresenter pres = obtainPresenterFactory(request.getContextPath()).createTimesheetChangePresenter(null); // Load the july timesheet into the presenter CouchDbTimesheetService tsService = new CouchDbTimesheetService(); List<Timesheet> tsList = tsService.listAllTimesheet(new HashMap<String, Object>(context)); for (Timesheet ts : tsList) { if (ts.getMonth() == 7 && ts.getYear() == 2014) { pres.setTimesheet(ts); break; } } // TODO: have list presenter before (instead of one) m.setCurrentComponent((Component) pres.getView().getComponent()); setContent(m); // and go pres.startPresenting(); }
Example #9
Source File: DemoUI.java From gantt with Apache License 2.0 | 6 votes |
@Override protected void init(VaadinRequest request) { ganttListener = null; createGantt(); MenuBar menu = controlsMenuBar(); Panel controls = createControls(); Component wrapper = UriFragmentWrapperFactory.wrapByUriFragment(UI.getCurrent().getPage().getUriFragment(), gantt); if (wrapper instanceof GanttListener) { ganttListener = (GanttListener) wrapper; } final VerticalLayout layout = new VerticalLayout(); layout.setStyleName("demoContentLayout"); layout.setMargin(false); layout.setSizeFull(); layout.addComponent(menu); layout.addComponent(controls); layout.addComponent(wrapper); layout.setExpandRatio(wrapper, 1); setContent(layout); }
Example #10
Source File: QuestionnairesUI.java From gazpachoquest with GNU General Public License v3.0 | 6 votes |
@Override public void init(VaadinRequest request) { logger.info("New Vaadin UI created"); String invitation = request.getParameter("invitation"); logger.info("Invitation: {} of sessions : {}", invitation); setSizeFull(); 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); } }
Example #11
Source File: Application.java From boot-examples with Apache License 2.0 | 6 votes |
@Override protected void init(VaadinRequest vaadinRequest) { getPage().setTitle("Root UI"); Table table = new Table("Customer Table"); table.addContainerProperty("firstName", String.class, null); table.addContainerProperty("lastName", String.class, null); table.addContainerProperty("id", Long.class, null); for (Customer c : this.customerRepository.findAll()) table.addItem(new Object[]{c.getFirstName(), c.getLastName(), c.getId()}, c.getId()); table.setSizeFull(); table.setColumnHeader("firstName", "First Name"); table.setColumnHeader("lastName", "First Name"); setContent(table); }
Example #12
Source File: SchemeRequestHandler.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { response.setContentType("text/css"); byte[] text = generateCss(); response.setCacheTime(-1); response.setStatus(HttpURLConnection.HTTP_OK); try (OutputStream stream = response.getOutputStream()) { response.setContentLength(text.length); stream.write(text); } return true; }
Example #13
Source File: SchemeRequestHandler.java From consulo with Apache License 2.0 | 6 votes |
private static boolean hasPathPrefix(VaadinRequest request, String prefix) { String pathInfo = request.getPathInfo(); if (pathInfo == null) { return false; } if (!prefix.startsWith("/")) { prefix = '/' + prefix; } if (pathInfo.startsWith(prefix)) { return true; } return false; }
Example #14
Source File: ContractApplicationExampleUI.java From vaadinator with Apache License 2.0 | 5 votes |
@Override protected void init(VaadinRequest request) { NavigationManager m = new NavigationManager(); m.setMaintainBreadcrumb(true); FirstPagePresenter fpres; fpres = obtainPresenterFactory(request.getContextPath()).createFirstPagePresenter(); FirstPageView fview = (FirstPageView) fpres.getView(); m.setCurrentComponent((Component) fview.getComponent()); setContent(m); // and go fpres.startPresenting(); }
Example #15
Source File: MyWindow.java From java-course-ee with MIT License | 5 votes |
@Override public void init(VaadinRequest vaadinRequest) { hLayout.setSpacing(true); hLayout.setMargin(true); datetime = new PopupDateField("Выберите дату: "); datetime.setValue(new Date()); datetime.setResolution(Resolution.HOUR); datetime.addValueChangeListener(new MyWindow.MyPropertyChangeListener()); datetime.setImmediate(true); datetime.setRequired(true); datetime.setRequiredError("Обязательно для заполнения"); datetime.setParseErrorMessage("Неправильный формат даты"); hLayout.addComponent(datetime); textField = new TextField("Выбранное значение: "); textField.setWidth(200, Unit.PIXELS); hLayout.addComponent(textField); mainWindow.setWidth(600, Unit.PIXELS); mainWindow.setHeight(200, Unit.PIXELS); mainWindow.center(); mainWindow.setContent(hLayout); addWindow(mainWindow); }
Example #16
Source File: AddressbookExampleUIEx.java From vaadinator with Apache License 2.0 | 5 votes |
@Override protected void init(VaadinRequest request) { // for mobile, set yet another theme if (VaadinServlet.getCurrent() instanceof TouchKitServlet) { setTheme("touchkitexex"); } super.init(request); }
Example #17
Source File: MyWindow.java From java-course-ee with MIT License | 5 votes |
@Override protected void init(VaadinRequest vaadinRequest) { mainWindow = new Window("Test Vaadin application"); mainWindow.setWidth(800, Unit.PIXELS); mainWindow.setHeight(600, Unit.PIXELS); mainWindow.center(); grid.setWidth("100%"); grid.setHeight(300, Unit.PIXELS); grid.setSelectionMode(Grid.SelectionMode.SINGLE); grid.setContainerDataSource(new BeanItemContainer<Person>(Person.class, DaoImpl.getAllPersons())); grid.setColumns("name", "birth"); Grid.Column bornColumn = grid.getColumn("birth"); bornColumn.setRenderer(new DateRenderer("%1$td-%1$tm-%1$tY")); grid.addSelectionListener(event -> { Set<Object> selected = event.getSelected(); Person o = (Person) selected.toArray()[0]; BeanFieldGroup.bindFieldsUnbuffered(o, formLayout); formLayout.id.setEnabled(true); formLayout.name.setEnabled(true); formLayout.birth.setEnabled(true); }); formLayout.id.setEnabled(false); formLayout.name.setEnabled(false); formLayout.birth.setEnabled(false); verticalLayout.setMargin(true); verticalLayout.addComponent(grid); verticalLayout.addComponent(formLayout); mainWindow.setContent(verticalLayout); addWindow(mainWindow); }
Example #18
Source File: DesktopApplication.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
private String printRequest(VaadinRequest request) { StringBuilder requestInfo = new StringBuilder(); Enumeration<String> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String attr = headerNames.nextElement(); requestInfo.append(attr).append(": ").append(request.getHeader(attr)).append('\n'); } requestInfo.append("Subdomain: ").append(UIUtils.getSubDomain(request)).append('\n'); requestInfo.append("Remote address: ").append(request.getRemoteAddr()).append('\n'); requestInfo.append("Path info: ").append(request.getPathInfo()).append('\n'); requestInfo.append("Remote smtphost: ").append(request.getRemoteHost()).append('\n'); return requestInfo.toString(); }
Example #19
Source File: MainUI.java From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 | 5 votes |
@Override protected void init(VaadinRequest request) { setLocale(new Locale.Builder().setLanguage("sr").setScript("Latn").setRegion("RS").build()); SecuredNavigator securedNavigator = new SecuredNavigator(MainUI.this, mainLayout, springViewProvider, security, eventBus); securedNavigator.addViewChangeListener(mainLayout); setContent(mainLayout); setErrorHandler(new SpringSecurityErrorHandler()); /* * Handling redirections */ // RequestAttributes attrs = RequestContextHolder.getRequestAttributes(); // if (sessionStrategy.getAttribute(attrs, VaadinRedirectObject.REDIRECT_OBJECT_SESSION_ATTRIBUTE) != null) { // VaadinRedirectObject redirectObject = (VaadinRedirectObject) sessionStrategy.getAttribute(attrs, VaadinRedirectObject.REDIRECT_OBJECT_SESSION_ATTRIBUTE); // sessionStrategy.removeAttribute(attrs, VaadinRedirectObject.REDIRECT_OBJECT_SESSION_ATTRIBUTE); // // navigator.navigateTo(redirectObject.getRedirectViewToken()); // // if (redirectObject.getErrorMessage() != null) { // Notification.show("Error", redirectObject.getErrorMessage(), Type.ERROR_MESSAGE); // } // // } }
Example #20
Source File: Java7LocaleNegotiationStrategy.java From viritin with Apache License 2.0 | 5 votes |
@Override public Locale negotiate(final List<Locale> supportedLocales, VaadinRequest vaadinRequest) { String languages = vaadinRequest.getHeader("Accept-Language"); ArrayList<Locale> preferredArray = new ArrayList<>( supportedLocales); if (languages != null) { final String[] priorityList = languages.split(","); Collections.sort(preferredArray, new Comparator<Locale>() { @Override public int compare(Locale o1, Locale o2) { int pos1 = supportedLocales.size(), pos2 = supportedLocales .size(); for (int i = 0; i < priorityList.length; i++) { String lang = priorityList[i].split("[_;-]")[0].trim(); if (lang.equals(o1.getLanguage())) { pos1 = i; } if (lang.equals(o2.getLanguage())) { pos2 = i; } } return pos1 - pos2; } }); } return preferredArray.get(0); }
Example #21
Source File: MyUI.java From designer-tutorials with Apache License 2.0 | 5 votes |
@Override protected void init(VaadinRequest vaadinRequest) { final ApplicationDesign design = new ApplicationDesign(); setContent(design); // This replaces a proper backend just to simulate how the view behaves // with dynamic content for (int i = 0; i < 10; i++) { design.messageList.addComponent(new Message()); } }
Example #22
Source File: UrlBeanNameUiMapping.java From jdal with Apache License 2.0 | 5 votes |
@Override public UI getUi(VaadinRequest request) { ApplicationContext ctx = VaadinUtils.getApplicationContext(); String beanName = getBeanNameFromRequest(request); if (beanName != null && ctx.containsBean(beanName)) return VaadinUtils.getApplicationContext().getBean(beanName, UI.class); return null; }
Example #23
Source File: DemoUI.java From vaadin-grid-util with MIT License | 5 votes |
@Override protected void init(final VaadinRequest request) { VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); layout.setMargin(true); layout.setSpacing(true); Grid<Inhabitants> grid = genGrid(); layout.addComponent(grid); layout.setExpandRatio(grid, 1); setContent(layout); }
Example #24
Source File: SessionStoreAdapterIT.java From vertx-vaadin with MIT License | 5 votes |
@Override protected void init(VaadinRequest request) { request.getService().addSessionDestroyListener(e -> { ((SessionTestVerticle) ((VertxVaadinService) e.getService()).getVertx().getOrCreateContext().get("mySelf")) .registerSessionEvent("Session destroyed"); }); }
Example #25
Source File: Demo.java From serverside-elements with Apache License 2.0 | 5 votes |
@Override protected void init(VaadinRequest request) { VerticalLayout layout = new VerticalLayout(); addDemo(layout, new Html5InputDemo(), "HTML5 inputs"); // Does not work in Firefox // tabSheet.addTab(new GoogleMapDemo(), "Web components"); addDemo(layout, new ExistingElementsDemo(), "Existing elements"); addDemo(layout, new PaperElementsDemo(), "Paper compoments"); layout.setMargin(true); // layout.setSpacing(true); setContent(layout); }
Example #26
Source File: ContextMenuUI.java From context-menu with Apache License 2.0 | 5 votes |
@Override protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); Button button = new Button("Button 1"); layout.addComponent(button); Button button2 = new Button("Button 2"); layout.addComponent(button2); ContextMenu contextMenu = new ContextMenu(this, false); fillMenu(contextMenu); contextMenu.setAsContextMenuOf(button); contextMenu.setAsContextMenuOf(button2); contextMenu.addContextMenuOpenListener( (ContextMenuOpenListener) event -> Notification.show("Context menu on" + event.getSourceComponent().getCaption())); contextMenu.setHtmlContentAllowed(true); layout.addComponent(new GridWithGenericListener()); layout.addComponent(new GridWithGridListener()); layout.addComponent(but3); layout.addComponent(new Button("Remove items from context menu", e -> contextMenu.removeItems())); addTree(layout); }
Example #27
Source File: ContextmenuUI.java From context-menu with Apache License 2.0 | 5 votes |
@Override protected void init(VaadinRequest request) { if (request.getParameter("treetable") != null) { setContent(new ContextMenuTreeTable()); } else { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); layout.addComponent(createVaadin7Grid()); } }
Example #28
Source File: CitizenIntelligenceAgencyUI.java From cia with Apache License 2.0 | 5 votes |
@Override protected void init(final VaadinRequest request) { VaadinSession.getCurrent().setErrorHandler(new UiInstanceErrorHandler(this)); setSizeFull(); springNavigator.addView(CRLF_REPLACEMENT, mainView); setNavigator(springNavigator); final Page currentPage = Page.getCurrent(); final String requestUrl = currentPage.getLocation().toString(); final String language = request.getLocale().getLanguage(); final UserConfiguration userConfiguration = configurationManager.getUserConfiguration(requestUrl, language); currentPage.setTitle(userConfiguration.getAgency().getAgencyName() + ":" + userConfiguration.getPortal().getPortalName() + ":" + userConfiguration.getLanguage().getLanguageName()); if (getSession().getUIs().isEmpty()) { final WebBrowser webBrowser = currentPage.getWebBrowser(); final CreateApplicationSessionRequest serviceRequest = new CreateApplicationSessionRequest(); serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); final String ipInformation = WebBrowserUtil.getIpInformation(webBrowser); serviceRequest.setIpInformation(ipInformation); serviceRequest.setTimeZone(webBrowser.getTimeZoneId()); serviceRequest.setScreenSize(webBrowser.getScreenWidth() + "x" + webBrowser.getScreenHeight()); serviceRequest.setUserAgentInformation(webBrowser.getBrowserApplication()); serviceRequest.setLocale(webBrowser.getLocale().toString()); serviceRequest.setOperatingSystem(WebBrowserUtil.getOperatingSystem(webBrowser)); serviceRequest.setSessionType(ApplicationSessionType.ANONYMOUS); final ServiceResponse serviceResponse = applicationManager.service(serviceRequest); LOGGER.info(LOG_INFO_BROWSER_ADDRESS_APPLICATION_SESSION_ID_RESULT,requestUrl.replaceAll(CRLF,CRLF_REPLACEMENT),language.replaceAll(CRLF,CRLF_REPLACEMENT),ipInformation.replaceAll(CRLF,CRLF_REPLACEMENT),webBrowser.getBrowserApplication().replaceAll(CRLF,CRLF_REPLACEMENT),serviceRequest.getSessionId().replaceAll(CRLF,CRLF_REPLACEMENT),serviceResponse.getResult().toString().replaceAll(CRLF,CRLF_REPLACEMENT)); } }
Example #29
Source File: LoginWindow.java From jpa-invoicer with The Unlicense | 5 votes |
@Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { if (request.getParameter("code") != null) { String code = request.getParameter("code"); Verifier v = new Verifier(code); Token t = service.getAccessToken(null, v); OAuthRequest r = new OAuthRequest(Verb.GET, "https://www.googleapis.com/plus/v1/people/me"); service.signRequest(t, r); Response resp = r.send(); GooglePlusAnswer answer = new Gson().fromJson(resp.getBody(), GooglePlusAnswer.class); userSession.login(answer.emails[0].value, answer.displayName); close(); VaadinSession.getCurrent().removeRequestHandler(this); ((VaadinServletResponse) response).getHttpServletResponse(). sendRedirect(redirectUrl); return true; } return false; }
Example #30
Source File: UrlBeanNameUiMapping.java From jdal with Apache License 2.0 | 5 votes |
/** * Lookup UI class from application context. * @param request request */ @Override @SuppressWarnings("unchecked") public Class<?extends UI> getUiClass(VaadinRequest request) { ApplicationContext ctx = VaadinUtils.getApplicationContext(); String beanName = getBeanNameFromRequest(request); if (beanName != null && ctx.containsBean(beanName)) return (Class<? extends UI>) ctx.getType(beanName); return null; }