public class ScopedLocalizableError extends LocalizableError
Provides a slightly more customizable approach to error messages. Where the LocalizedError class looks for an error message in a single place based on the key provided, ScopedLocalizableError performs a scoped search for an error message.
As an example, let's say that the IntegerConverter raises an error message with the values defaultScope=converter.integer and key=outOfRange, for a field called age on an ActionBean bound to /cats/KittenDetail.action. Based on this information an instance of ScopedLocalizableError would fetch the resource bundle and look for error message templates in the following order:
Using ScopingLocalizedErrors provides application developers with the flexibility to provide as much or as little specificity in error messages as desired. The scope and ordering of the messages is designed to allow developers to specify default messages at several levels, and then override those as needed for specific circumstances.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_NAME
Default key that is used for looking up error messages.
|
Constructor and Description |
---|
ScopedLocalizableError(java.lang.String defaultScope,
java.lang.String key,
java.lang.Object... parameters)
Constructs a ScopedLocalizableError with the supplied information.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o)
Generated equals method that checks all fields and super.equals().
|
java.lang.String |
getDefaultScope()
Get the default scope that was passed into the constructor.
|
java.lang.String |
getKey()
Get the key that was passed into the constructor.
|
protected java.lang.String |
getMessageTemplate(java.util.Locale locale)
Overrides getMessageTemplate to perform a scoped search for a message template as defined in
the class level javadoc.
|
int |
hashCode()
Generated hashCode() method.
|
getMessageKey
getActionPath, getBeanclass, getFieldName, getFieldValue, getMessage, resolveFieldName, setActionPath, setBeanclass, setFieldName, setFieldValue
getMessage, getReplacementParameters
public static final java.lang.String DEFAULT_NAME
public ScopedLocalizableError(java.lang.String defaultScope, java.lang.String key, java.lang.Object... parameters)
defaultScope
- the default scope under which to look for the error message should more
specifically scoped lookups failkey
- the name of the message to lookupparameters
- an optional number of replacement parameters to be used in the messagepublic java.lang.String getDefaultScope()
public java.lang.String getKey()
protected java.lang.String getMessageTemplate(java.util.Locale locale)
getMessageTemplate
in class LocalizableError
locale
- the Locale of the message template desiredpublic boolean equals(java.lang.Object o)
equals
in class LocalizableError
o
- another object that is a SimpleMessage or subclass thereofpublic int hashCode()
hashCode
in class LocalizableError
? Copyright 2005-2006, Stripes Development Team.