Class UrlPathThemeResolver

java.lang.Object
org.springframework.web.util.CookieGenerator
org.springframework.web.servlet.theme.CookieThemeResolver
net.solarnetwork.web.support.UrlPathThemeResolver
All Implemented Interfaces:
org.springframework.web.servlet.ThemeResolver

public class UrlPathThemeResolver extends org.springframework.web.servlet.theme.CookieThemeResolver
ThemeResolver that resolves a theme name from a URL path variable.

This class extends CookieThemeResolver and as such uses cookies to persist the theme with the client browser. The theme can be changed (or initially set) by passing a URL path variable with the HTTP request, for example /path/to/something.html;theme=mytheme.

The configurable properties of this class are:

themePathVariable
The name of the URL path variable to look for the current theme in. Defaults to DEFAULT_THEME_PATH_VARIABLE.
Version:
1.0
Author:
matt
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Default value for the themePathVariable property.

    Fields inherited from class org.springframework.web.servlet.theme.CookieThemeResolver

    DEFAULT_COOKIE_NAME, ORIGINAL_DEFAULT_THEME_NAME, THEME_REQUEST_ATTRIBUTE_NAME

    Fields inherited from class org.springframework.web.util.CookieGenerator

    DEFAULT_COOKIE_PATH, logger
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the theme path variable name.
    resolveThemeName(javax.servlet.http.HttpServletRequest request)
     
    void
    setThemePathVariable(String themePathVariable)
    Set the theme path variable name.

    Methods inherited from class org.springframework.web.servlet.theme.CookieThemeResolver

    getDefaultThemeName, setDefaultThemeName, setThemeName

    Methods inherited from class org.springframework.web.util.CookieGenerator

    addCookie, createCookie, getCookieDomain, getCookieMaxAge, getCookieName, getCookiePath, isCookieHttpOnly, isCookieSecure, removeCookie, setCookieDomain, setCookieHttpOnly, setCookieMaxAge, setCookieName, setCookiePath, setCookieSecure

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_THEME_PATH_VARIABLE

      public static final String DEFAULT_THEME_PATH_VARIABLE
      Default value for the themePathVariable property.
      See Also:
  • Constructor Details

    • UrlPathThemeResolver

      public UrlPathThemeResolver()
      Default constructor.
  • Method Details

    • resolveThemeName

      public String resolveThemeName(javax.servlet.http.HttpServletRequest request)
      Specified by:
      resolveThemeName in interface org.springframework.web.servlet.ThemeResolver
      Overrides:
      resolveThemeName in class org.springframework.web.servlet.theme.CookieThemeResolver
    • getThemePathVariable

      public String getThemePathVariable()
      Get the theme path variable name.
      Returns:
      the variable name
    • setThemePathVariable

      public void setThemePathVariable(String themePathVariable)
      Set the theme path variable name.
      Parameters:
      themePathVariable - the path variable name