Examples of LocaleResolver


Examples of org.springframework.web.servlet.LocaleResolver

   * the plain request
   * @see #getLocaleResolver
   * @see javax.servlet.http.HttpServletRequest#getLocale()
   */
  public static Locale getLocale(HttpServletRequest request) {
    LocaleResolver localeResolver = getLocaleResolver(request);
    if (localeResolver != null) {
      return localeResolver.resolveLocale(request);
    }
    else {
      return request.getLocale();
    }
  }
View Full Code Here

Examples of org.springframework.web.servlet.LocaleResolver

  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
      throws ServletException {

    String newLocale = request.getParameter(this.paramName);
    if (newLocale != null) {
      LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
      if (localeResolver == null) {
        throw new IllegalStateException("No LocaleResolver found: not in a DispatcherServlet request?");
      }
      localeResolver.setLocale(request, response, StringUtils.parseLocaleString(newLocale));
    }
    // Proceed in any case.
    return true;
  }
View Full Code Here

Examples of org.springframework.web.servlet.LocaleResolver

        SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME);
    if (locale == null) {
      locale = this.setUserLocale(request, response);
    }
    if (locale != null) {
      LocaleResolver resolver = RequestContextUtils.getLocaleResolver(request);
      if (resolver != null) {
        resolver.setLocale(request, response, locale);
      }
    }
    return super.preHandle(request, response, handler);
  }
View Full Code Here

Examples of org.springframework.web.servlet.LocaleResolver

    Locale locale = (Locale)request.getSession().getAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME);
    if (locale == null) {
      locale = this.setUserLocale(request, response);
    }
    if (locale != null) {
      LocaleResolver resolver = RequestContextUtils.getLocaleResolver(request);
      if (resolver != null) {
        resolver.setLocale(request, response, locale);
      }
    }
    return super.preHandle(request, response, handler);
  }
View Full Code Here

Examples of org.springframework.web.servlet.LocaleResolver

  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
      throws ServletException {

    String newLocale = request.getParameter(this.paramName);
    if (newLocale != null) {
      LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
      if (localeResolver == null) {
        throw new IllegalStateException("No LocaleResolver found: not in a DispatcherServlet request?");
      }
      LocaleEditor localeEditor = new LocaleEditor();
      localeEditor.setAsText(newLocale);
      localeResolver.setLocale(request, response, (Locale) localeEditor.getValue());
    }
    // Proceed in any case.
    return true;
  }
View Full Code Here

Examples of org.springframework.web.servlet.LocaleResolver

    // Fetch WebApplicationContext, either from DispatcherServlet or the root context.
    // ServletContext needs to be specified to be able to fall back to the root context!
    this.webApplicationContext = RequestContextUtils.getWebApplicationContext(request, servletContext);

    // Determine locale to use for this RequestContext.
    LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
    if (localeResolver != null) {
      // Try LocaleResolver (we're within a DispatcherServlet request).
      this.locale = localeResolver.resolveLocale(request);
    }
    else {
      // No LocaleResolver available -> try fallback.
      this.locale = getFallbackLocale();
    }
View Full Code Here

Examples of org.springframework.web.servlet.LocaleResolver

   * the plain request
   * @see #getLocaleResolver
   * @see javax.servlet.http.HttpServletRequest#getLocale()
   */
  public static Locale getLocale(HttpServletRequest request) {
    LocaleResolver localeResolver = getLocaleResolver(request);
    if (localeResolver != null) {
      return localeResolver.resolveLocale(request);
    }
    else {
      return request.getLocale();
    }
  }
View Full Code Here

Examples of org.springframework.web.servlet.LocaleResolver

    MockHttpServletRequest request = new MockHttpServletRequest(sc);
    MockHttpServletResponse response = new MockHttpServletResponse();
    if (inDispatcherServlet()) {
      request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
      LocaleResolver lr = new AcceptHeaderLocaleResolver();
      request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, lr);
      ThemeResolver tr = new FixedThemeResolver();
      request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, tr);
      request.setAttribute(DispatcherServlet.THEME_SOURCE_ATTRIBUTE, wac);
    }
View Full Code Here

Examples of org.springframework.web.servlet.LocaleResolver

    Cell cell = sheet.getCell(0, 0);
    assertEquals("Test Template auf Deutsch", cell.getContents());
  }

  private LocaleResolver newDummyLocaleResolver(final String lang, final String country) {
    return new LocaleResolver() {
      public Locale resolveLocale(HttpServletRequest request) {
        return new Locale(lang, country);
      }

      public void setLocale(HttpServletRequest request,
View Full Code Here

Examples of org.springframework.web.servlet.LocaleResolver

      session.setAttribute(UserAttributes.NAME, userAttrs);
    }
   
    String langCode = request.getParameter(this.languageParam);
    if (langCode != null) {
      LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
      if (localeResolver == null) {
        throw new IllegalStateException("No LocaleResolver found: not in a DispatcherServlet request?");
      }
     
      Locale locale = StringUtils.parseLocaleString(langCode);
      localeResolver.setLocale(request, response, locale);
     
      Language language = languageService.getByCode(langCode);
      if(language!=null){
        userAttrs.setLanguageId(language.getId());
        locale = language.getLocale();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.