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,
ContentNegotiatingViewResolverFORWARD_URL_PREFIX, REDIRECT_URL_PREFIX| Constructor and Description |
|---|
LiteDeviceDelegatingViewResolver(org.springframework.web.servlet.ViewResolver delegate)
Creates a new LiteDeviceDelegatingViewResolver
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
getDeviceViewNameInternal(java.lang.String viewName)
Subclasses must implement this method, adjusting the device view name
based on device resolution used within the subclass.
|
protected java.lang.String |
getMobilePrefix()
Return the prefix that gets prepended to view names for mobile devices
|
protected java.lang.String |
getMobileSuffix()
Return the suffix that gets appended to view names for mobile devices
|
protected java.lang.String |
getNormalPrefix()
Return the prefix that gets prepended to view names for normal devices
|
protected java.lang.String |
getNormalSuffix()
Return the suffix that gets appended to view names for normal devices
|
protected java.lang.String |
getTabletPrefix()
Return the prefix that gets prepended to view names for tablet devices
|
protected java.lang.String |
getTabletSuffix()
Return the suffix that gets appended to view names for tablet devices
|
void |
setMobilePrefix(java.lang.String mobilePrefix)
Set the prefix that gets prepended to view names for mobile devices.
|
void |
setMobileSuffix(java.lang.String mobileSuffix)
Set the suffix that gets appended to view names for mobile devices
|
void |
setNormalPrefix(java.lang.String normalPrefix)
Set the prefix that gets prepended to view names for normal devices.
|
void |
setNormalSuffix(java.lang.String normalSuffix)
Set the suffix that gets appended to view names for normal devices.
|
void |
setTabletPrefix(java.lang.String tabletPrefix)
Set the prefix that gets prepended to view names for tablet devices.
|
void |
setTabletSuffix(java.lang.String tabletSuffix)
Set the suffix that gets appended to view names for tablet devices
|
getDeviceViewName, getEnableFallback, getOrder, getViewResolver, initServletContext, resolveViewName, setEnableFallback, setOrdergetServletContext, getTempDir, getWebApplicationContext, initApplicationContext, isContextRequired, setServletContextpublic LiteDeviceDelegatingViewResolver(org.springframework.web.servlet.ViewResolver delegate)
delegate - the ViewResolver in which to delegatepublic void setNormalPrefix(java.lang.String normalPrefix)
protected java.lang.String getNormalPrefix()
public void setMobilePrefix(java.lang.String mobilePrefix)
protected java.lang.String getMobilePrefix()
public void setTabletPrefix(java.lang.String tabletPrefix)
protected java.lang.String getTabletPrefix()
public void setNormalSuffix(java.lang.String normalSuffix)
protected java.lang.String getNormalSuffix()
public void setMobileSuffix(java.lang.String mobileSuffix)
protected java.lang.String getMobileSuffix()
public void setTabletSuffix(java.lang.String tabletSuffix)
protected java.lang.String getTabletSuffix()
protected java.lang.String getDeviceViewNameInternal(java.lang.String viewName)
AbstractDeviceDelegatingViewResolvergetDeviceViewNameInternal in class AbstractDeviceDelegatingViewResolverviewName - the name of the view before device resolutionAbstractDeviceDelegatingViewResolver.getDeviceViewName(String)