|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.stripes.validation.SimpleError
net.sourceforge.stripes.validation.LocalizableError
public class LocalizableError
Provides a mechanism for creating localizable error messages for presentation to the user. Uses ResourceBundles to provide the localization of the error message. Messages may contain one or more "replacement parameters ". Two replacement parameters are provided by default, they are the field name and field value, and are indices 0 and 1 respectively. To use replacement parameters a message must contain the replacement token {#} where # is the numeric index of the replacement parameter.
For example, to construct an error message with one additional replacement parameter which is the action the user was trying to perform, you might have a properties file entry like:
/action/MyAction.myErrorMessage={1} is not a valid {0} when trying to {2}
At runtime this might get replaced out to result in an error message for the user that looks like "Fixed is not a valid status when trying to create a new bug".
One last point of interest is where the user friendly field name comes from. Firstly an attempt is made to look up the localized name in the applicable resource bundle using the String actionPath.fieldName where actionPath is the action of the form in the JSP (or equally, the path given in the @UrlBinding annotation in the ActionBean class), and fieldName is the name of the field on the form.
MessageFormat,
ResourceBundle| Field Summary | |
|---|---|
static Log |
log
Log class used to log debugging information. |
| Fields inherited from class net.sourceforge.stripes.validation.SimpleError |
|---|
replacementParameters |
| Constructor Summary | |
|---|---|
LocalizableError(String messageKey,
Object... parameter)
Creates a new LocalizableError with the message key provided, and optionally zero or more replacement parameters to use in the message. |
|
| Method Summary | |
|---|---|
boolean |
equals(Object o)
Generated equals method that compares each field and super.equals(). |
protected String |
getMessageTemplate(Locale locale)
Method responsible for using the information supplied to the error object to find a message template. |
int |
hashCode()
Generated hashCode method. |
| Methods inherited from class net.sourceforge.stripes.validation.SimpleError |
|---|
getActionPath, getFieldName, getFieldValue, getMessage, resolveFieldName, setActionPath, setFieldName, setFieldValue |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Log log
| Constructor Detail |
|---|
public LocalizableError(String messageKey,
Object... parameter)
messageKey - a key to lookup a message in the resource bundleparameter - one or more replacement parameters to insert into the message| Method Detail |
|---|
protected String getMessageTemplate(Locale locale)
getMessageTemplate in class SimpleErrorlocale - the Locale of the message template desired
public boolean equals(Object o)
equals in class SimpleErrorpublic int hashCode()
hashCode in class SimpleError
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||