public abstract class AbstractDeviceDelegatingViewResolver extends WebApplicationObjectSupport implements ViewResolver
ViewResolver
implementation, providing a device
aware ViewResolver
wrapper that delegates to another view resolver
implementation, allowing for resolution of device specific view names without
the need for a dedicated mapping to be defined for each view.LiteDeviceDelegatingViewResolver
Modifier and Type | Field and Description |
---|---|
static String |
FORWARD_URL_PREFIX
Prefix for special view names that specify a forward URL (usually
to a controller after a form has been submitted and processed).
|
static String |
REDIRECT_URL_PREFIX
Prefix for special view names that specify a redirect URL (usually
to a controller after a form has been submitted and processed).
|
logger
Modifier | Constructor and Description |
---|---|
protected |
AbstractDeviceDelegatingViewResolver(ViewResolver delegate)
Creates a new AbstractDeviceDelegatingViewResolver
|
Modifier and Type | Method and Description |
---|---|
protected String |
getDeviceViewName(String viewName)
Returns the adjusted view name as determined by subclass implementation.
|
protected abstract String |
getDeviceViewNameInternal(String viewName)
Subclasses must implement this method, adjusting the device view name
based on device resolution used within the subclass.
|
protected boolean |
getEnableFallback()
Return whether fallback view resolution is enabled
|
ViewResolver |
getViewResolver()
Returns the delegate view resolver
|
protected void |
initServletContext(ServletContext servletContext) |
View |
resolveViewName(String viewName,
Locale locale) |
void |
setEnableFallback(boolean enableFallback)
Enables support for fallback resolution, meaning if the adjusted view
name cannot be resolved, and attempt will be made to resolve the
original view name.
|
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
public static final String REDIRECT_URL_PREFIX
public static final String FORWARD_URL_PREFIX
protected AbstractDeviceDelegatingViewResolver(ViewResolver delegate)
delegate
- the ViewResolver in which to delegatepublic ViewResolver getViewResolver()
public void setEnableFallback(boolean enableFallback)
Note: fallback resolution will only work when delegating to a view
resolver which returns null from
resolveViewName(String, Locale)
if it cannot resolve a view.
For example, InternalResourceViewResolver
never returns null,
so fallback resolution will not be available.
protected boolean getEnableFallback()
setEnableFallback(boolean)
public View resolveViewName(String viewName, Locale locale) throws Exception
resolveViewName
in interface ViewResolver
Exception
protected String getDeviceViewName(String viewName)
viewName
- the name of the view before device resolutiongetDeviceViewNameInternal(String)
protected abstract String getDeviceViewNameInternal(String viewName)
viewName
- the name of the view before device resolutiongetDeviceViewName(String)
protected void initServletContext(ServletContext servletContext)
initServletContext
in class WebApplicationObjectSupport