Expert Spring MVC and Web Flow

(Dana P.) #1
Figure 5-3 illustrates the class hierarchy for the ThemeResolverand its subclasses.

Figure 5-3.ThemeResolver class hierarchy


The DispatcherServletdoes not support chaining of ThemeResolvers. It will simply attempt
to find a bean in the ApplicationContextwith the name themeResolver. If no ThemeResolvers are
located, then the DispatcherServletwill create its own FixedThemeResolverconfigured only with
the defaults.
Working with the configured ThemeResolveris no different than working with the
LocaleResolver. The DispatcherServletplaces the ThemeResolverinto each request as an
HttpServletRequestattribute. You then access this object through the RequestContextUtils
utility class and its getThemeResolver()method.


Summary


A theme is a skin, or look and feel, for your web application that is easily changed by the user
or application. The ThemeResolverinterface encapsulates the strategy for reading and setting
the theme for a user’s request. Similar to the LocaleResolver, the ThemeResolversupports a
fixed theme, or storing the theme in a cookie or in the HttpSessionobject.
The DispatcherServletwill look for a bean with the name themeResolverin
the ApplicationContextupon startup. If it does not find one, it will use the default
FixedThemeResolver.
We’ll discuss themes in detail in Chapter 7. For now, it’s important to know that
there is one for each DispatcherServletand the default, if none are specified, is the
FixedThemeResolver.


AbstractThemeResolver

SessionThemeResolver

CookieThemeResolver

FixedThemeResolver

CookieGenerator

<<interface>>
ThemeResolver

CHAPTER 5 ■THE PROCESSING PIPELINE 113
Free download pdf