org.springframework.web.servlet.theme

Class CookieThemeResolver

    • Field Detail

      • ORIGINAL_DEFAULT_THEME_NAME

        public static final java.lang.String ORIGINAL_DEFAULT_THEME_NAME
        The default theme name used if no alternative is provided.
        See Also:
        Constant Field Values
      • THEME_REQUEST_ATTRIBUTE_NAME

        public static final java.lang.String THEME_REQUEST_ATTRIBUTE_NAME
        Name of the request attribute that holds the theme name. Only used for overriding a cookie value if the theme has been changed in the course of the current request! Use RequestContext.getTheme() to retrieve the current theme in controllers or views.
        See Also:
        RequestContext.getTheme()
      • DEFAULT_COOKIE_NAME

        public static final java.lang.String DEFAULT_COOKIE_NAME
        The default name of the cookie that holds the theme name.
    • Constructor Detail

      • CookieThemeResolver

        public CookieThemeResolver()
    • Method Detail

      • setDefaultThemeName

        public void setDefaultThemeName(java.lang.String defaultThemeName)
        Set the name of the default theme.
      • getDefaultThemeName

        public java.lang.String getDefaultThemeName()
        Return the name of the default theme.
      • resolveThemeName

        public java.lang.String resolveThemeName(HttpServletRequest request)
        Description copied from interface: ThemeResolver
        Resolve the current theme name via the given request. Should return a default theme as fallback in any case.
        Specified by:
        resolveThemeName in interface ThemeResolver
        Parameters:
        request - request to be used for resolution
        Returns:
        the current theme name
      • setThemeName

        public void setThemeName(HttpServletRequest request,
                                 @Nullable
                                 HttpServletResponse response,
                                 @Nullable
                                 java.lang.String themeName)
        Description copied from interface: ThemeResolver
        Set the current theme name to the given one.
        Specified by:
        setThemeName in interface ThemeResolver
        Parameters:
        request - request to be used for theme name modification
        response - response to be used for theme name modification
        themeName - the new theme name (null or empty to reset it)