public class LiteDeviceDelegatingViewResolver extends AbstractDeviceDelegatingViewResolver
AbstractDeviceDelegatingViewResolver
for adjusting a
view based on the combination of resolved Device
and specified
SitePreference
. View names can be augmented with a specified prefix
or suffix.
Specify the prefix for the different device types. Default prefixes are empty strings. For the requested view name of "home", the following table illustrates how the view name will be adjusted based on device type.
Resolved Device | Method | Prefix | Adjusted View |
Normal | setNormalPrefix(String) |
"normal/" | "normal/home" |
Mobile | setMobilePrefix(String) |
"mobile/" | "mobile/home" |
Tablet | setTabletPrefix(String) |
"tablet/" | "tablet/home" |
Alternatively, you may want to have the views adjusted to use a suffix for each device type. Again, using the requested view name of "home", the following table shows the adjusted view names.
Resolved Device | Method | Suffix | Adjusted View |
Normal | setNormalSuffix(String) |
".normal" | "home.normal" |
Mobile | setMobileSuffix(String) |
".mobile" | "home.mobile" |
Tablet | setTabletSuffix(String) |
".tablet" | "home.tablet" |
It is also possible to use a combination of prefix and suffix. The view resolver will apply both to the adjusted view.
ViewResolver
,
ContentNegotiatingViewResolver
FORWARD_URL_PREFIX, REDIRECT_URL_PREFIX
logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
LiteDeviceDelegatingViewResolver(ViewResolver delegate)
Creates a new LiteDeviceDelegatingViewResolver
|
Modifier and Type | Method and Description |
---|---|
protected String |
getDeviceViewNameInternal(String viewName)
Subclasses must implement this method, adjusting the device view name
based on device resolution used within the subclass.
|
protected String |
getMobilePrefix()
Return the prefix that gets prepended to view names for mobile devices
|
protected String |
getMobileSuffix()
Return the suffix that gets appended to view names for mobile devices
|
protected String |
getNormalPrefix()
Return the prefix that gets prepended to view names for normal devices
|
protected String |
getNormalSuffix()
Return the suffix that gets appended to view names for normal devices
|
protected String |
getTabletPrefix()
Return the prefix that gets prepended to view names for tablet devices
|
protected String |
getTabletSuffix()
Return the suffix that gets appended to view names for tablet devices
|
void |
setMobilePrefix(String mobilePrefix)
Set the prefix that gets prepended to view names for mobile devices.
|
void |
setMobileSuffix(String mobileSuffix)
Set the suffix that gets appended to view names for mobile devices
|
void |
setNormalPrefix(String normalPrefix)
Set the prefix that gets prepended to view names for normal devices.
|
void |
setNormalSuffix(String normalSuffix)
Set the suffix that gets appended to view names for normal devices.
|
void |
setTabletPrefix(String tabletPrefix)
Set the prefix that gets prepended to view names for tablet devices.
|
void |
setTabletSuffix(String tabletSuffix)
Set the suffix that gets appended to view names for tablet devices
|
getDeviceViewName, getEnableFallback, getOrder, getViewResolver, initServletContext, resolveViewName, setEnableFallback, setOrder
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
public LiteDeviceDelegatingViewResolver(ViewResolver delegate)
delegate
- the ViewResolver in which to delegatepublic void setNormalPrefix(String normalPrefix)
protected String getNormalPrefix()
public void setMobilePrefix(String mobilePrefix)
protected String getMobilePrefix()
public void setTabletPrefix(String tabletPrefix)
protected String getTabletPrefix()
public void setNormalSuffix(String normalSuffix)
protected String getNormalSuffix()
public void setMobileSuffix(String mobileSuffix)
protected String getMobileSuffix()
public void setTabletSuffix(String tabletSuffix)
protected String getTabletSuffix()
protected String getDeviceViewNameInternal(String viewName)
AbstractDeviceDelegatingViewResolver
getDeviceViewNameInternal
in class AbstractDeviceDelegatingViewResolver
viewName
- the name of the view before device resolutionAbstractDeviceDelegatingViewResolver.getDeviceViewName(String)