org.springframework.web.servlet.theme
Class CookieThemeResolver

org.springframework.web.servlet.theme.AbstractThemeResolver
  |
  +--org.springframework.web.servlet.theme.CookieThemeResolver

public class CookieThemeResolver
extends AbstractThemeResolver

Implementation of ThemeResolver that uses a cookie sent back to the user in case of a custom setting, with a fallback to the fixed locale. This is especially useful for stateless applications without user sessions.

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

Author:
Jean-Pierre Pawlak, Juergen Hoeller
Since: 17.06.2003

Field Summary
 final static intDEFAULT_COOKIE_MAX_AGE
           
 final static StringDEFAULT_COOKIE_NAME
           
 final static StringDEFAULT_COOKIE_PATH
           
 final static StringTHEME_REQUEST_ATTRIBUTE_NAME
          Name of the request attribute that holds the theme name.

Fields inherited from class org.springframework.web.servlet.theme.AbstractThemeResolver
ORIGINAL_DEFAULT_THEME_NAME

Method Summary
 intgetCookieMaxAge()
           
 StringgetCookieName()
           
 StringgetCookiePath()
          Use the given path for theme cookies.
 StringresolveThemeName(HttpServletRequest request)
           
 voidsetCookieMaxAge(int cookieMaxAge)
          Use the given maximum age, specified in seconds, for locale cookies.
 voidsetCookieName(String cookieName)
          Use the given name for theme cookies, containing the theme name.
 voidsetCookiePath(String cookiePath)
           
 voidsetThemeName(HttpServletRequest request, HttpServletResponse response, String themeName)
           

Methods inherited from class org.springframework.web.servlet.theme.AbstractThemeResolver
getDefaultThemeName, makeThemeNameAvailable, setDefaultThemeName

Field Detail

DEFAULT_COOKIE_MAX_AGE

public final static int DEFAULT_COOKIE_MAX_AGE

DEFAULT_COOKIE_NAME

public final static String DEFAULT_COOKIE_NAME

DEFAULT_COOKIE_PATH

public final static String DEFAULT_COOKIE_PATH

THEME_REQUEST_ATTRIBUTE_NAME

public final static 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()
Method Detail

getCookieMaxAge

public int getCookieMaxAge()

getCookieName

public String getCookieName()

getCookiePath

public String getCookiePath()
Use the given path for theme cookies. The cookie is only visible for URLs in the path and below.

resolveThemeName

public String resolveThemeName(HttpServletRequest request)

setCookieMaxAge

public void setCookieMaxAge(int cookieMaxAge)
Use the given maximum age, specified in seconds, for locale cookies. Useful special value: -1 ... not persistent, deleted when client shuts down

setCookieName

public void setCookieName(String cookieName)
Use the given name for theme cookies, containing the theme name.

setCookiePath

public void setCookiePath(String cookiePath)

setThemeName

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

Association Links

to Class java.lang.String

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 org.springframework.web.servlet.support.RequestContext#getTheme

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String