Java Reference
In-Depth Information
Now, field labels are defined in one place and reused in the contact
view, in the contact form, and in error messages. Nice!
With labels in resource bundles, we can still use different labels for
fields that are in different forms but have the same name. Just put the
package and class name of the action bean in front of the field name,
as in the following:
Download email_14/res/StripesResources.properties
stripesbook.action.ContactFormActionBean.contact.firstName=FIRST NAME
stripesbook.action.ContactFormActionBean.contact.lastName=LAST NAME
stripesbook.action.ContactFormActionBean.contact.email=EMAIL
stripesbook.action.ContactFormActionBean.contact.phoneNumber=PHONE NUMBER
stripesbook.action.ContactFormActionBean.contact.birthDate=BIRTH DATE
contact.firstName=first name
contact.lastName=last name
contact.email=email
contact.phoneNumber=phone number
contact.birthDate=birth date
This would use uppercase labels in the contact form and lowercase
labels everywhere else.
Changing the Error Message Text
If changing field labels is not enough to get the error messages that we
want, we can change the text completely. By default, Stripes looks for
an error message in the StripesResources.properties file. When a validation
error occurs, Stripes uses several keys to search for the correspond-
ing message. The keys go from more specific to more general, making it
possible to have very specific messages as well as general-purpose mes-
sages. The StripesResources.properties file you copied over from the Stripes
distribution contains messages for all possible errors that Stripes pro-
duces, using the most general key.
We can change the text either by overriding the Stripes default or by
providing a message using a more specific key. Let's talk a bit more
about these keys.
To build the list of search keys, Stripes uses different combinations of
the following values:
actionBeanFullName: The fully qualified name of the action bean class,
as in stripesbook.action.ContactFormActionBean .
 
 
 
Search WWH ::




Custom Search