public class SiteSwitcherRequestFilter extends OncePerRequestFilter
The initialization parameters available for configuring the servlet filter:
switcherMode
serverName
tabletIsMobile
mobilePath
tabletPath
rootPath
The switcherMode
init parameter requires that you specify one of three values. And for each of these
values, the corresponding additional required init params are listed.
mDot
serverName
is requiredtabletIsMobile
is optionaldotMobi
serverName
is requiredtabletIsMobile
is optionalurlPath
mobilePath
is optionaltabletPath
is optionalrootPath
is optionalThe following examples illustrate the different parameter configurations.
Creates a site switcher that switches between app.com
and m.app.com
:
<init-param> <param-name>switcherMode</param-name> <param-value>mDot</param-value> <param-name>serverName</param-name> <param-value>app.com</param-value> </init-param>
Creates a site switcher that switches between app.com
and app.mobi
:
<init-param> <param-name>switcherMode</param-name> <param-value>dotMobi</param-value> <param-name>serverName</param-name> <param-value>app.com</param-value> </init-param>
By default tablets are presented with the 'normal' site when using mDot
or
dotMobi
. However you can have the site switcher direct tablets to the mobile site by
setting the tabletIsMobile
parameter to true.
<init-param> <param-name>switcherMode</param-name> <param-value>mDot</param-value> <param-name>serverName</param-name> <param-value>app.com</param-value> <param-name>tabletIsMobile</param-name> <param-value>true</param-value> </init-param>
Creates a site switcher that switches between app.com
and app.com/mob/
for mobile devices, and app.com
and app.com/tab/
for tablet devices:
<init-param> <param-name>switcherMode</param-name> <param-value>urlPath</param-value> <param-name>mobilePath</param-name> <param-value>mob</param-value> <param-name>tabletPath</param-name> <param-value>tab</param-value> </init-param>
ALREADY_FILTERED_SUFFIX
logger
Constructor and Description |
---|
SiteSwitcherRequestFilter() |
SiteSwitcherRequestFilter(SiteUrlFactory normalSiteUrlFactory,
SiteUrlFactory mobileSiteUrlFactory,
SiteUrlFactory tabletSiteUrlFactory,
SitePreferenceHandler sitePreferenceHandler)
Creates a new site switcher.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain filterChain) |
String |
getMobilePath() |
String |
getRootPath() |
String |
getServerName() |
String |
getSwitcherMode() |
Boolean |
getTabletIsMobile() |
String |
getTabletPath() |
protected void |
initFilterBean() |
void |
setMobilePath(String mobilePath) |
void |
setRootPath(String rootPath) |
void |
setServerName(String serverName) |
void |
setSwitcherMode(String switcherMode) |
void |
setTabletIsMobile(Boolean tabletIsMobile) |
void |
setTabletPath(String tabletPath) |
doFilter, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch
addRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, setBeanName, setEnvironment, setServletContext
public SiteSwitcherRequestFilter()
public SiteSwitcherRequestFilter(SiteUrlFactory normalSiteUrlFactory, SiteUrlFactory mobileSiteUrlFactory, SiteUrlFactory tabletSiteUrlFactory, SitePreferenceHandler sitePreferenceHandler)
normalSiteUrlFactory
- the factory for a "normal" site URL e.g. http://app.commobileSiteUrlFactory
- the factory for a "mobile" site URL e.g. http://m.app.comtabletSiteUrlFactory
- the factory for a "tablet" sitesitePreferenceHandler
- the handler for the user site preferencepublic String getSwitcherMode()
public void setSwitcherMode(String switcherMode)
public String getServerName()
public void setServerName(String serverName)
public Boolean getTabletIsMobile()
public void setTabletIsMobile(Boolean tabletIsMobile)
public String getMobilePath()
public void setMobilePath(String mobilePath)
public String getTabletPath()
public void setTabletPath(String tabletPath)
public String getRootPath()
public void setRootPath(String rootPath)
protected void initFilterBean() throws ServletException
initFilterBean
in class GenericFilterBean
ServletException
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException
doFilterInternal
in class OncePerRequestFilter
ServletException
IOException