org.riotfamily.common.web.view
Class SuffixViewResolver

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.view.AbstractCachingViewResolver
              extended by org.riotfamily.common.web.view.SuffixViewResolver
All Implemented Interfaces:
ApplicationContextAware, Ordered, ServletContextAware, ViewResolver

public class SuffixViewResolver
extends AbstractCachingViewResolver
implements Ordered

View resolver that supports view names with a suffix. For example someView.jsp would be delegated to the ViewResolver registered for the jsp suffix.


Field Summary
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).
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
SuffixViewResolver()
           
 
Method Summary
 int getOrder()
          Return the order in which this ViewResolver is evaluated.
protected  View loadView(String viewName, Locale locale)
           
 void setDefaultSuffix(String defaultSuffix)
          Sets a default suffix that will be appended to view names that don't contain a dot.
 void setOrder(int order)
          Set the order in which this ViewResolver is evaluated.
 void setRedirectContextRelative(boolean redirectContextRelative)
          Set whether to interpret a given redirect URL that starts with a slash ("/") as relative to the current ServletContext, i.e. as relative to the web application root.
 void setRedirectHttp10Compatible(boolean redirectHttp10Compatible)
          Set whether redirects should stay compatible with HTTP 1.0 clients.
 void setResolvers(Map<String,ViewResolver> resolvers)
           
 
Methods inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver
clearCache, createView, getCacheKey, isCache, removeFromCache, resolveViewName, setCache
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REDIRECT_URL_PREFIX

public static final 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). Such view names will not be resolved in the configured default way but rather be treated as special shortcut.

See Also:
Constant Field Values

FORWARD_URL_PREFIX

public static final 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). Such view names will not be resolved in the configured default way but rather be treated as special shortcut.

See Also:
Constant Field Values
Constructor Detail

SuffixViewResolver

public SuffixViewResolver()
Method Detail

setResolvers

public void setResolvers(Map<String,ViewResolver> resolvers)
Parameters:
resolvers - ViewResolvers keyed by suffix (without dots).

setDefaultSuffix

public void setDefaultSuffix(String defaultSuffix)
Sets a default suffix that will be appended to view names that don't contain a dot. If set to null (default), view names without an extension won't be resolved which allows resolver chaining.


setRedirectContextRelative

public void setRedirectContextRelative(boolean redirectContextRelative)
Set whether to interpret a given redirect URL that starts with a slash ("/") as relative to the current ServletContext, i.e. as relative to the web application root.

Default is "true": A redirect URL that starts with a slash will be interpreted as relative to the web application root, i.e. the context path will be prepended to the URL.

Redirect URLs can be specified via the "redirect:" prefix. E.g.: "redirect:myAction.do"

See Also:
RedirectView.setContextRelative(boolean), REDIRECT_URL_PREFIX

setRedirectHttp10Compatible

public void setRedirectHttp10Compatible(boolean redirectHttp10Compatible)
Set whether redirects should stay compatible with HTTP 1.0 clients.

In the default implementation, this will enforce HTTP status code 302 in any case, i.e. delegate to HttpServletResponse.sendRedirect. Turning this off will send HTTP status code 303, which is the correct code for HTTP 1.1 clients, but not understood by HTTP 1.0 clients.

Many HTTP 1.1 clients treat 302 just like 303, not making any difference. However, some clients depend on 303 when redirecting after a POST request; turn this flag off in such a scenario.

Redirect URLs can be specified via the "redirect:" prefix. E.g.: "redirect:myAction.do"

See Also:
RedirectView.setHttp10Compatible(boolean), REDIRECT_URL_PREFIX

setOrder

public void setOrder(int order)
Set the order in which this ViewResolver is evaluated. Default is Ordered.LOWEST_PRECEDENCE.


getOrder

public int getOrder()
Return the order in which this ViewResolver is evaluated.

Specified by:
getOrder in interface Ordered

loadView

protected View loadView(String viewName,
                        Locale locale)
                 throws Exception
Specified by:
loadView in class AbstractCachingViewResolver
Throws:
Exception