Class ResourceBundleViewResolver

All Implemented Interfaces:
ApplicationContextAware, ViewResolver

public class ResourceBundleViewResolver
extends AbstractCachingViewResolver

Implementation of ViewResolver that uses bean definitions in a ResourceBundle, specified by the bundle basename. The bundle is typically defined in a properties file, located in the classpath.

This ViewResolver supports internationalization, using the default support of java.util.PropertyResourceBundle.

Extends AbstractCachingViewResolver for decent performance.

Rod Johnson, Juergen Hoeller
See Also:
ResourceBundle.getBundle(java.lang.String), java.util.PropertyResourceBundle

Field Summary
static java.lang.String DEFAULT_BASENAME
          Default if no other basename is supplied
Fields inherited from class
Constructor Summary
Method Summary
protected  BeanFactory initFactory(java.util.Locale locale)
          Initialize the BeanFactory from the ResourceBundle, for the given locale.
protected  View loadView(java.lang.String viewName, java.util.Locale locale)
          Subclasses must implement this method.
 void setBasename(java.lang.String basename)
          Set the basename, as defined in the java.util.ResourceBundle documentation.
 void setDefaultParentView(java.lang.String defaultParentView)
          Set the default parent for views defined in the ResourceBundle.
Methods inherited from class com.interface21.web.servlet.view.AbstractCachingViewResolver
isCache, resolveViewName, setCache
Methods inherited from class
getApplicationContext, initApplicationContext, setApplicationContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.interface21.context.ApplicationContextAware

Field Detail


public static final java.lang.String DEFAULT_BASENAME
Default if no other basename is supplied
Constructor Detail


public ResourceBundleViewResolver()
Method Detail


public void setBasename(java.lang.String basename)
Set the basename, as defined in the java.util.ResourceBundle documentation. ResourceBundle supports different suffixes. For example, a base name of "views" might map to ResourceBundle files "views", "views_en_au" and "views_de".

The default is "views".

basename - the ResourceBundle base name
See Also:


public void setDefaultParentView(java.lang.String defaultParentView)
Set the default parent for views defined in the ResourceBundle. This avoids repeated "yyy1.parent=xxx", "yyy2.parent=xxx" definitions in the bundle, especially if all defined views share the same parent. The parent will typically define the view class and common attributes. Concrete views might simply consist of an URL definition then: a la "yyy1.url=/my.jsp", "yyy2.url=/your.jsp".
defaultParentView - the default parent view


protected View loadView(java.lang.String viewName,
                        java.util.Locale locale)
                 throws javax.servlet.ServletException
Description copied from class: AbstractCachingViewResolver
Subclasses must implement this method. There need be no concern for efficiency, as this class will cache views. Not all subclasses may support internationalization: A subclass that doesn't can ignore the locale parameter.
loadView in class AbstractCachingViewResolver
Following copied from class: com.interface21.web.servlet.view.AbstractCachingViewResolver
viewName - name of the view to retrieve
locale - Locale to retrieve the view for
the View if it can be resolved, or null
javax.servlet.ServletException - if there is an error trying to resolve the view


protected BeanFactory initFactory(java.util.Locale locale)
                           throws java.util.MissingResourceException,
Initialize the BeanFactory from the ResourceBundle, for the given locale. Synchronized because of access by parallel threads.

Rod Johnson and Spring contributors 2001-2003.