net.sourceforge.stripes.localization
Class DefaultLocalizationBundleFactory

java.lang.Object
  extended by net.sourceforge.stripes.localization.DefaultLocalizationBundleFactory
All Implemented Interfaces:
ConfigurableComponent, LocalizationBundleFactory

public class DefaultLocalizationBundleFactory
extends Object
implements LocalizationBundleFactory

Very simple default implementation of a bundle factory. Looks for configuration parameters in the bootstrap properties called "LocalizationBundleFactory.ErrorMessageBundle" and "LocalizationBundleFactory.FieldNameBundle". If one or both of these values is not specified the default bundle name of "StripesResources" will be used in its place.

Author:
Tim Fennell
See Also:
BootstrapPropertyResolver

Field Summary
static String BUNDLE_NAME
          The name of the default resource bundle for Stripes.
static String ERROR_MESSAGE_BUNDLE
          The configuration parameter for changing the default error message resource bundle.
static String FIELD_NAME_BUNDLE
          The configuration parameter for changing the default field name resource bundle.
 
Constructor Summary
DefaultLocalizationBundleFactory()
           
 
Method Summary
protected  Configuration getConfiguration()
           
 ResourceBundle getErrorMessageBundle(Locale locale)
          Looks for a bundle called StripesResources with the supplied locale if one is provided, or with the default locale if the locale provided is null.
 ResourceBundle getFormFieldBundle(Locale locale)
          Looks for a bundle called StripesResources with the supplied locale if one is provided, or with the default locale if the locale provided is null.
 void init(Configuration configuration)
          Uses the BootstrapPropertyResolver attached to the Configuration in order to look for configured bundle names in the servlet init parameters etc.
protected  void setConfiguration(Configuration configuration)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUNDLE_NAME

public static final String BUNDLE_NAME
The name of the default resource bundle for Stripes.

See Also:
Constant Field Values

ERROR_MESSAGE_BUNDLE

public static final String ERROR_MESSAGE_BUNDLE
The configuration parameter for changing the default error message resource bundle.

See Also:
Constant Field Values

FIELD_NAME_BUNDLE

public static final String FIELD_NAME_BUNDLE
The configuration parameter for changing the default field name resource bundle.

See Also:
Constant Field Values
Constructor Detail

DefaultLocalizationBundleFactory

public DefaultLocalizationBundleFactory()
Method Detail

init

public void init(Configuration configuration)
          throws Exception
Uses the BootstrapPropertyResolver attached to the Configuration in order to look for configured bundle names in the servlet init parameters etc. If those can't be found then the default bundle names are put in place.

Specified by:
init in interface ConfigurableComponent
Parameters:
configuration - the Configuration object being used by Stripes
Throws:
Exception - should be thrown if the component cannot be configured well enough to use.

getErrorMessageBundle

public ResourceBundle getErrorMessageBundle(Locale locale)
                                     throws MissingResourceException
Looks for a bundle called StripesResources with the supplied locale if one is provided, or with the default locale if the locale provided is null.

Specified by:
getErrorMessageBundle in interface LocalizationBundleFactory
Parameters:
locale - an optional locale, may be null.
Returns:
ResourceBundle a bundle in which to look for localized error messages
Throws:
MissingResourceException - if a suitable bundle cannot be found

getFormFieldBundle

public ResourceBundle getFormFieldBundle(Locale locale)
                                  throws MissingResourceException
Looks for a bundle called StripesResources with the supplied locale if one is provided, or with the default locale if the locale provided is null.

Specified by:
getFormFieldBundle in interface LocalizationBundleFactory
Parameters:
locale - an optional locale, may be null.
Returns:
ResourceBundle a bundle in which to look for localized field names
Throws:
MissingResourceException - if a suitable bundle cannot be found

getConfiguration

protected Configuration getConfiguration()

setConfiguration

protected void setConfiguration(Configuration configuration)


? Copyright 2005-2006, Stripes Development Team.