Top Description Fields Constructors Methods
org.springframework.web.servlet.theme

public Class CookieThemeResolver

extends CookieGenerator
implements ThemeResolver
Class Inheritance
All Implemented Interfaces
org.springframework.web.servlet.ThemeResolver
Annotations
@Deprecated
since:6.0
Imports
jakarta.servlet.http.Cookie, .HttpServletRequest, .HttpServletResponse, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringUtils, org.springframework.web.servlet.ThemeResolver, org.springframework.web.util.CookieGenerator, .WebUtils

Deprecated

since 6.0.

as of 6.0 in favor of using CSS, without direct replacement

ThemeResolver implementation that uses a cookie sent back to the user in case of a custom setting, with a fallback to the default theme. This is particularly useful for stateless applications without user sessions.

Custom controllers can thus override the user's theme by calling setThemeName, e.g. responding to a certain theme change request.

Authors
Jean-Pierre Pawlak, Juergen Hoeller
Since
17.06.2003
See Also
setThemeName

Field Summary

Modifier and TypeField and Description
private String
public static final String
ORIGINAL_DEFAULT_THEME_NAME

The default theme name used if no alternative is provided.

public static final String
THEME_REQUEST_ATTRIBUTE_NAME

Name of the request attribute that holds the theme name.

Inherited from org.springframework.web.util.CookieGenerator:
DEFAULT_COOKIE_PATHlogger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
getDefaultThemeName()

Return the name of the default theme.

public String
resolveThemeName(HttpServletRequest
the request to be used for resolution
request
)

Implements org.springframework.web.servlet.ThemeResolver.resolveThemeName.

Resolve the current theme name via the given request.

public void
setDefaultThemeName(String defaultThemeName)

Set the name of the default theme.

public void
setThemeName(HttpServletRequest
the request to be used for theme name modification
request
,
HttpServletResponse
the response to be used for theme name modification
response
,
String
the new theme name (null or empty to reset it)
themeName
)

Implements org.springframework.web.servlet.ThemeResolver.setThemeName.

Set the current theme name to the given one.

Inherited from org.springframework.web.util.CookieGenerator:
addCookiecreateCookiegetCookieDomaingetCookieMaxAgegetCookieNamegetCookiePathisCookieHttpOnlyisCookieSecureremoveCookiesetCookieDomainsetCookieHttpOnlysetCookieMaxAgesetCookieNamesetCookiePathsetCookieSecure

Field Detail

defaultThemeNameback to summary
private String defaultThemeName
ORIGINAL_DEFAULT_THEME_NAMEback to summary
public static final String ORIGINAL_DEFAULT_THEME_NAME

The default theme name used if no alternative is provided.

THEME_REQUEST_ATTRIBUTE_NAMEback to summary
public static final 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
org.springframework.web.servlet.support.RequestContext#getTheme

Constructor Detail

CookieThemeResolverback to summary
public CookieThemeResolver()

Method Detail

getDefaultThemeNameback to summary
public String getDefaultThemeName()

Return the name of the default theme.

resolveThemeNameback to summary
public String resolveThemeName(HttpServletRequest request)

Implements org.springframework.web.servlet.ThemeResolver.resolveThemeName.

Doc from org.springframework.web.servlet.ThemeResolver.resolveThemeName.

Resolve the current theme name via the given request. Should return a default theme as fallback in any case.

Parameters
request:HttpServletRequest

the request to be used for resolution

Returns:String

the current theme name

Annotations
@Override
setDefaultThemeNameback to summary
public void setDefaultThemeName(String defaultThemeName)

Set the name of the default theme.

setThemeNameback to summary
public void setThemeName(HttpServletRequest request, HttpServletResponse response, String themeName)

Implements org.springframework.web.servlet.ThemeResolver.setThemeName.

Doc from org.springframework.web.servlet.ThemeResolver.setThemeName.

Set the current theme name to the given one.

Parameters
request:HttpServletRequest

the request to be used for theme name modification

response:HttpServletResponse

the response to be used for theme name modification

themeName:String

the new theme name (null or empty to reset it)

Annotations
@Override