com.interface21.web.servlet.view
Class ResourceBundleViewResolver

java.lang.Object
  |
  +--com.interface21.context.support.ApplicationObjectSupport
        |
        +--com.interface21.web.servlet.view.AbstractCachingViewResolver
              |
              +--com.interface21.web.servlet.view.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.

Author:
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 com.interface21.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
ResourceBundleViewResolver()
           
 
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 com.interface21.context.support.ApplicationObjectSupport
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
setApplicationContext
 

Field Detail

DEFAULT_BASENAME

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

ResourceBundleViewResolver

public ResourceBundleViewResolver()
Method Detail

setBasename

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".

Parameters:
basename - the ResourceBundle base name
See Also:
ResourceBundle

setDefaultParentView

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".
Parameters:
defaultParentView - the default parent view

loadView

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.
Overrides:
loadView in class AbstractCachingViewResolver
Following copied from class: com.interface21.web.servlet.view.AbstractCachingViewResolver
Parameters:
viewName - name of the view to retrieve
locale - Locale to retrieve the view for
Returns:
the View if it can be resolved, or null
Throws:
javax.servlet.ServletException - if there is an error trying to resolve the view

initFactory

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


Rod Johnson and Spring contributors 2001-2003.