Java Reference
In-Depth Information
Figure 6.5: Customizing the display of error messages
Error Messages Next to Fields
Stripes makes it easy to display error messages individually, next to
nice because the user doesn't have to read the error messages at the
top and then scan down the form to figure out to which field each
message refers.
If you indicate the name of a field in the
field=
attribute of the <s:errors>
tag, only the error messages for that field will be displayed. The value
for
field=
must match the
name=
attribute of the corresponding input
field. For example, this would display error messages concerning the
contact's email next to the email field:
<td>
Email:
</td>
<td><s:text name="contact.email"/></td>
<td><s:errors field="contact.email"/></td>
After adding <s:errors> tags with the
field=
attribute next to each input
field, we can remove the <s:errors/> tag at the top. Now, to display the
messages with the error icon, the entries that start with
stripes.fieldErrors
must be modified:
stripes.fieldErrors.header=
stripes.fieldErrors.beforeError=<img src="images/error.gif"/>\
<span class="error">
stripes.fieldErrors.afterError=</span><br/>
stripes.fieldErrors.footer=
Search WWH ::
Custom Search