|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.stripes.action.SimpleMessage
net.sourceforge.stripes.validation.SimpleError
net.sourceforge.stripes.validation.LocalizableError
net.sourceforge.stripes.validation.ScopedLocalizableError
public class ScopedLocalizableError
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.
Field Summary | |
---|---|
static String |
DEFAULT_NAME
Default key that is used for looking up error messages. |
Constructor Summary | |
---|---|
ScopedLocalizableError(String defaultScope,
String key,
Object... parameters)
Constructs a ScopedLocalizableError with the supplied information. |
Method Summary | |
---|---|
boolean |
equals(Object o)
Generated equals method that checks all fields and super.equals(). |
String |
getDefaultScope()
Get the default scope that was passed into the constructor. |
String |
getKey()
Get the key that was passed into the constructor. |
protected String |
getMessageTemplate(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. |
Methods inherited from class net.sourceforge.stripes.validation.LocalizableError |
---|
getMessageKey |
Methods inherited from class net.sourceforge.stripes.validation.SimpleError |
---|
getActionPath, getBeanclass, getFieldName, getFieldValue, getMessage, resolveFieldName, setActionPath, setBeanclass, setFieldName, setFieldValue |
Methods inherited from class net.sourceforge.stripes.action.SimpleMessage |
---|
getMessage, getReplacementParameters |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_NAME
Constructor Detail |
---|
public ScopedLocalizableError(String defaultScope, String key, 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 messageMethod Detail |
---|
public String getDefaultScope()
ScopedLocalizableError(String, String, Object...)
public String getKey()
ScopedLocalizableError(String, String, Object...)
protected String getMessageTemplate(Locale locale)
getMessageTemplate
in class LocalizableError
locale
- the Locale of the message template desired
public boolean equals(Object o)
equals
in class LocalizableError
o
- another object that is a SimpleMessage or subclass thereof
public int hashCode()
hashCode
in class LocalizableError
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |