org.springframework.mobile.device.site
Class StandardSitePreferenceHandler
java.lang.Object
org.springframework.mobile.device.site.StandardSitePreferenceHandler
- All Implemented Interfaces:
- SitePreferenceHandler
public class StandardSitePreferenceHandler
- extends java.lang.Object
- implements SitePreferenceHandler
A helper that resolves the user's site preference and makes it available as a request attribute.
Primarily used to support the case where a user on a mobile device prefers to use the normal site.
The site preference may be changed on behalf of a user by submitting the 'site_preference' query parameter.
The preference value is saved in a repository so it can be remembered until the user decides to change it again.
If no site preference is specified, preference to the mobile site will be given if the current device is a mobile device.
The current user SitePreference is exported as a request attribute with the name SitePreferenceHandler.CURRENT_SITE_PREFERENCE_ATTRIBUTE.
This allows handler mappings and view resolvers further down the line to vary their logic by site preference.
- Author:
- Keith Donald
|
Method Summary |
SitePreference |
handleSitePreference(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handle the site preference aspect of the web request. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StandardSitePreferenceHandler
public StandardSitePreferenceHandler(SitePreferenceRepository sitePreferenceRepository)
- Creates a new site preference handler.
- Parameters:
sitePreferenceRepository - the store for recording user site preference
handleSitePreference
public SitePreference handleSitePreference(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
- Description copied from interface:
SitePreferenceHandler
- Handle the site preference aspect of the web request.
Implementations should check if the user has indicated a site preference.
If so, the indicated site preference should be saved and remembered for future requests.
If no site preference has been indicated, an implementation may derive a default site preference from the
Device that originated the request.
After handling, the resolved site preference is available as a request attribute.
- Specified by:
handleSitePreference in interface SitePreferenceHandler
- Parameters:
request - the web requestresponse - the web response
- Returns:
- the resolved site preference for the user that originated the web request