com.interface21.web.servlet.theme
Class CookieThemeResolver

java.lang.Object
  |
  +--com.interface21.web.servlet.theme.AbstractThemeResolver
        |
        +--com.interface21.web.servlet.theme.CookieThemeResolver
All Implemented Interfaces:
ThemeResolver

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.

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

Field Summary
static int DEFAULT_COOKIE_MAX_AGE
           
static java.lang.String DEFAULT_COOKIE_NAME
           
static java.lang.String THEME_REQUEST_ATTRIBUTE_NAME
           
 
Fields inherited from class com.interface21.web.servlet.theme.AbstractThemeResolver
ORIGINAL_DEFAULT_THEME_NAME
 
Constructor Summary
CookieThemeResolver()
           
 
Method Summary
 int getCookieMaxAge()
           
 java.lang.String getCookieName()
           
 java.lang.String resolveThemeName(javax.servlet.http.HttpServletRequest request)
          Resolve the current theme name via the given request.
 void setCookieMaxAge(int cookieMaxAge)
          Use the given maximum age, specified in seconds, for locale cookies.
 void setCookieName(java.lang.String cookieName)
          Use the given name for theme cookies.
 void setThemeName(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String themeName)
          Set the current theme name to the given one.
 
Methods inherited from class com.interface21.web.servlet.theme.AbstractThemeResolver
getDefaultThemeName, setDefaultThemeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THEME_REQUEST_ATTRIBUTE_NAME

public static final java.lang.String THEME_REQUEST_ATTRIBUTE_NAME

DEFAULT_COOKIE_NAME

public static final java.lang.String DEFAULT_COOKIE_NAME

DEFAULT_COOKIE_MAX_AGE

public static final int DEFAULT_COOKIE_MAX_AGE
Constructor Detail

CookieThemeResolver

public CookieThemeResolver()
Method Detail

setCookieName

public void setCookieName(java.lang.String cookieName)
Use the given name for theme cookies.

getCookieName

public java.lang.String getCookieName()

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

getCookieMaxAge

public int getCookieMaxAge()

resolveThemeName

public java.lang.String resolveThemeName(javax.servlet.http.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.
Following copied from interface: com.interface21.web.servlet.ThemeResolver
Parameters:
request - request to be used for resolution
Returns:
the current theme name

setThemeName

public void setThemeName(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response,
                         java.lang.String themeName)
Description copied from interface: ThemeResolver
Set the current theme name to the given one.
Following copied from interface: com.interface21.web.servlet.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


Rod Johnson and Spring contributors 2001-2003.