Class SessionLocaleResolver

  • All Implemented Interfaces:
    LocaleResolver

    public class SessionLocaleResolver
    extends AbstractLocaleResolver
    LocaleResolver implementation that uses a locale attribute in the user's session in case of a custom setting, with a fallback to the specified default locale or the request's accept-header locale.

    Created: 2016. 3. 13.

    • Field Detail

      • LOCALE_SESSION_ATTRIBUTE_NAME

        public static final java.lang.String LOCALE_SESSION_ATTRIBUTE_NAME
        Name of the session attribute that holds the Locale. Only used internally by this implementation. to retrieve the current locale in controllers or views.
      • TIME_ZONE_SESSION_ATTRIBUTE_NAME

        public static final java.lang.String TIME_ZONE_SESSION_ATTRIBUTE_NAME
        Name of the session attribute that holds the TimeZone. Only used internally by this implementation.
    • Constructor Detail

      • SessionLocaleResolver

        public SessionLocaleResolver()
    • Method Detail

      • resolveLocale

        public java.util.Locale resolveLocale​(Translet translet)
        Description copied from interface: LocaleResolver
        Resolve the current locale via the given translet. Can return a default locale as fallback in any case.
        Parameters:
        translet - the translet to resolve the locale for
        Returns:
        the current locale (never null)
      • resolveTimeZone

        public java.util.TimeZone resolveTimeZone​(Translet translet)
        Description copied from interface: LocaleResolver
        Resolve the current timezone via the given translet. Can return a default timezone as fallback in any case.
        Parameters:
        translet - the translet to resolve the timezone for
        Returns:
        the current timezone (never null)
      • setLocale

        public void setLocale​(Translet translet,
                              java.util.Locale locale)
        Description copied from interface: LocaleResolver
        Set the current locale to the given one.
        Specified by:
        setLocale in interface LocaleResolver
        Overrides:
        setLocale in class AbstractLocaleResolver
        Parameters:
        translet - the translet to resolve the locale for
        locale - the new locale, or null to clear the locale
      • setTimeZone

        public void setTimeZone​(Translet translet,
                                java.util.TimeZone timeZone)
        Description copied from interface: LocaleResolver
        Set the current timezone to the given one.
        Specified by:
        setTimeZone in interface LocaleResolver
        Overrides:
        setTimeZone in class AbstractLocaleResolver
        Parameters:
        translet - the translet to resolve the locale for
        timeZone - the new timezone, or null to clear the timezone