Package org.springframework.context.i18n

Examples of org.springframework.context.i18n.LocaleContext


    // see RequestContextListener.requestInitialized()
    try {
      LocaleContextHolder.setLocale(httpRequest.getLocale());
      RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpRequest));

      LocaleContext servletLocaleContext = LocaleContextHolder.getLocaleContext();
      RequestAttributes servletRequestAttrs = RequestContextHolder.getRequestAttributes();

      MockActionRequest request = new MockActionRequest();
      MockActionResponse response = new MockActionResponse();
      request.setParameter("action", "invalid");
View Full Code Here


    // see RequestContextListener.requestInitialized()
    try {
      LocaleContextHolder.setLocale(httpRequest.getLocale());
      RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpRequest));

      LocaleContext servletLocaleContext = LocaleContextHolder.getLocaleContext();
      RequestAttributes servletRequestAttrs = RequestContextHolder.getRequestAttributes();

      MockRenderRequest request = new MockRenderRequest();
      MockRenderResponse response = new MockRenderResponse();
      try {
View Full Code Here

    if (logger.isDebugEnabled()) {
      logger.debug("DispatcherPortlet with name '" + getPortletName() + "' received action request");
    }

    // Expose current LocaleResolver and request as LocaleContext.
    LocaleContext previousLocaleContext = LocaleContextHolder.getLocaleContext();
    LocaleContextHolder.setLocaleContext(buildLocaleContext(request), this.threadContextInheritable);

    // Expose current RequestAttributes to current thread.
    RequestAttributes previousRequestAttributes = RequestContextHolder.getRequestAttributes();
    PortletRequestAttributes requestAttributes = new PortletRequestAttributes(request);
View Full Code Here

    if (logger.isDebugEnabled()) {
      logger.debug("DispatcherPortlet with name '" + getPortletName() + "' received render request");
    }

    // Expose current LocaleResolver and request as LocaleContext.
    LocaleContext previousLocaleContext = LocaleContextHolder.getLocaleContext();
    LocaleContextHolder.setLocaleContext(buildLocaleContext(request), this.threadContextInheritable);

    // Expose current RequestAttributes to current thread.
    RequestAttributes previousRequestAttributes = RequestContextHolder.getRequestAttributes();
    PortletRequestAttributes requestAttributes = new PortletRequestAttributes(request);
View Full Code Here

   * @return the PostMethod instance
   * @throws IOException if thrown by I/O methods
   */
  protected PostMethod createPostMethod(HttpInvokerClientConfiguration config) throws IOException {
    PostMethod postMethod = new PostMethod(config.getServiceUrl());
    LocaleContext locale = LocaleContextHolder.getLocaleContext();
    if (locale != null) {
      postMethod.addRequestHeader(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale.getLocale()));
    }
    if (isAcceptGzipEncoding()) {
      postMethod.addRequestHeader(HTTP_HEADER_ACCEPT_ENCODING, ENCODING_GZIP);
    }
    return postMethod;
View Full Code Here

   * @param request current HTTP request
   * @return the corresponding LocaleContext
   */
  @Override
  protected LocaleContext buildLocaleContext(final HttpServletRequest request) {
    return new LocaleContext() {
      public Locale getLocale() {
        return localeResolver.resolveLocale(request);
      }
      @Override
      public String toString() {
View Full Code Here

   * @return the HttpPost instance
   * @throws java.io.IOException if thrown by I/O methods
   */
  protected HttpPost createHttpPost(HttpInvokerClientConfiguration config) throws IOException {
    HttpPost httpPost = new HttpPost(config.getServiceUrl());
    LocaleContext localeContext = LocaleContextHolder.getLocaleContext();
    if (localeContext != null) {
      Locale locale = localeContext.getLocale();
      if (locale != null) {
        httpPost.addHeader(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale));
      }
    }
    if (isAcceptGzipEncoding()) {
View Full Code Here

    connection.setDoOutput(true);
    connection.setRequestMethod(HTTP_METHOD_POST);
    connection.setRequestProperty(HTTP_HEADER_CONTENT_TYPE, getContentType());
    connection.setRequestProperty(HTTP_HEADER_CONTENT_LENGTH, Integer.toString(contentLength));

    LocaleContext localeContext = LocaleContextHolder.getLocaleContext();
    if (localeContext != null) {
      Locale locale = localeContext.getLocale();
      if (locale != null) {
        connection.setRequestProperty(HTTP_HEADER_ACCEPT_LANGUAGE, StringUtils.toLanguageTag(locale));
      }
    }
    if (isAcceptGzipEncoding()) {
View Full Code Here

    request.setCookies(cookie);

    CookieLocaleResolver resolver = new CookieLocaleResolver();
    // yup, koekje is the Dutch name for Cookie ;-)
    resolver.setCookieName("LanguageKoekje");
    LocaleContext loc = resolver.resolveLocaleContext(request);
    assertEquals("nl", loc.getLocale().getLanguage());
    assertTrue(loc instanceof TimeZoneAwareLocaleContext);
    assertNull(((TimeZoneAwareLocaleContext) loc).getTimeZone());
  }
View Full Code Here

    request.setCookies(cookie);

    CookieLocaleResolver resolver = new CookieLocaleResolver();
    // yup, koekje is the Dutch name for Cookie ;-)
    resolver.setCookieName("LanguageKoekje");
    LocaleContext loc = resolver.resolveLocaleContext(request);
    assertEquals("nl", loc.getLocale().getLanguage());
    assertTrue(loc instanceof TimeZoneAwareLocaleContext);
    assertEquals(TimeZone.getTimeZone("GMT+1"), ((TimeZoneAwareLocaleContext) loc).getTimeZone());
  }
View Full Code Here

TOP

Related Classes of org.springframework.context.i18n.LocaleContext

Copyright © 2018 www.massapicom. 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.