Locale locale = request.getLocale(); if (locale != null) { return locale;
/** * Returns the JSON which should be returned to the client when a request * for a non-existent UI arrives. * * @param service * The VaadinService * @param vaadinRequest * The request which triggered this, or null if not available * @since 7.1 * @return A JSON string */ static String getUINotFoundErrorJSON(VaadinService service, VaadinRequest vaadinRequest) { SystemMessages ci = service.getSystemMessages(vaadinRequest.getLocale(), vaadinRequest); // Session Expired is not really the correct message as the // session exists but the requested UI does not. // Using Communication Error for now. String json = VaadinService.createCriticalNotificationJSON( ci.getCommunicationErrorCaption(), ci.getCommunicationErrorMessage(), null, ci.getCommunicationErrorURL()); return json; }
/** * Creates and registers a new VaadinSession for this service. Assumes * proper locking has been taken care of by the caller. * * * @param request * The request which triggered session creation. * @return A new VaadinSession instance * @throws ServiceException */ private VaadinSession createAndRegisterSession(VaadinRequest request) throws ServiceException { assert ((ReentrantLock) getSessionLock(request.getWrappedSession())) .isHeldByCurrentThread() : "Session has not been locked by this thread"; VaadinSession session = createVaadinSession(request); VaadinSession.setCurrent(session); storeSession(session, request.getWrappedSession()); // Initial WebBrowser data comes from the request session.getBrowser().updateRequestDetails(request); // Initial locale comes from the request Locale locale = request.getLocale(); session.setLocale(locale); session.setConfiguration(getDeploymentConfiguration()); session.setCommunicationManager( new LegacyCommunicationManager(session)); ServletPortletHelper.initDefaultUIProvider(session, this); onVaadinSessionStarted(request, session); return session; }
/** * For internal use by VaadinServlet/VaadinPortlet only. Updates all * properties in the class according to the given information. * * @param request * the Vaadin request to read the information from */ public void updateRequestDetails(VaadinRequest request) { locale = request.getLocale(); address = request.getRemoteAddr(); secureConnection = request.isSecure(); // Headers are case insensitive according to the specification but are // case sensitive in Weblogic portal... String agent = request.getHeader("User-Agent"); if (agent != null) { browserApplication = agent; browserDetails = new VBrowserDetails(agent); } if (request.getParameter("v-sw") != null) { updateClientSideDetails(request.getParameter("v-sw"), request.getParameter("v-sh"), request.getParameter("v-tzo"), request.getParameter("v-rtzo"), request.getParameter("v-dstd"), request.getParameter("v-dston"), request.getParameter("v-tzid"), request.getParameter("v-curdate"), request.getParameter("v-td") != null); } }
Locale locale = request.getLocale(); if (locale != null) { return locale;
@Override protected void writeBrowserTooOldPage(VaadinRequest request, VaadinResponse response) throws IOException { try (BufferedWriter page = new BufferedWriter(new OutputStreamWriter( response.getOutputStream(), StandardCharsets.UTF_8))) { Locale locale = request.getLocale(); ParamsMap paramsMap = ParamsMap.of() .pair("captionMessage", messages.getMainMessage("unsupportedPage.captionMessage", locale)) .pair("descriptionMessage", messages.getMainMessage("unsupportedPage.descriptionMessage", locale)) .pair("browserListCaption", messages.getMainMessage("unsupportedPage.browserListCaption", locale)) .pair("chromeMessage", messages.getMainMessage("unsupportedPage.chromeMessage", locale)) .pair("firefoxMessage", messages.getMainMessage("unsupportedPage.firefoxMessage", locale)) .pair("safariMessage", messages.getMainMessage("unsupportedPage.safariMessage", locale)) .pair("operaMessage", messages.getMainMessage("unsupportedPage.operaMessage", locale)) .pair("edgeMessage", messages.getMainMessage("unsupportedPage.edgeMessage", locale)) .pair("explorerMessage", messages.getMainMessage("unsupportedPage.explorerMessage", locale)); String template = resources.getResourceAsString(webConfig.getUnsupportedPagePath()); String pageContent = TemplateHelper.processTemplate(template, paramsMap.create()); page.write(pageContent); } } }
/** * Creates and registers a new VaadinSession for this service. Assumes * proper locking has been taken care of by the caller. * * * @param request * The request which triggered session creation. * @return A new VaadinSession instance * @throws ServiceException */ private VaadinSession createAndRegisterSession(VaadinRequest request) throws ServiceException { assert ((ReentrantLock) getSessionLock(request.getWrappedSession())) .isHeldByCurrentThread() : "Session has not been locked by this thread"; VaadinSession session = createVaadinSession(request); VaadinSession.setCurrent(session); storeSession(session, request.getWrappedSession()); // Initial WebBrowser data comes from the request session.getBrowser().updateRequestDetails(request); // Initial locale comes from the request Locale locale = request.getLocale(); session.setLocale(locale); session.setConfiguration(getDeploymentConfiguration()); onVaadinSessionStarted(request, session); return session; }
app.init(request.getLocale());
/** * For internal use only. Updates all properties in the class according to * the given information. * * @param request * the Vaadin request to read the information from */ public void updateRequestDetails(VaadinRequest request) { locale = request.getLocale(); address = request.getRemoteAddr(); secureConnection = request.isSecure(); // Headers are case insensitive according to the specifiation but are // case sensitive in Weblogic portal... String agent = request.getHeader("User-Agent"); if (agent != null) { browserApplication = agent; browserDetails = new BrowserDetails(agent); } if (request.getParameter("v-sw") != null) { updateClientSideDetails(request.getParameter("v-sw"), request.getParameter("v-sh"), request.getParameter("v-tzo"), request.getParameter("v-rtzo"), request.getParameter("v-dstd"), request.getParameter("v-dston"), request.getParameter("v-curdate"), request.getParameter("v-td") != null); } }
Locale requestLocale = currentRequest.getLocale(); setLocale(resolveLocale(requestLocale));