Java Reference
In-Depth Information
Joe Asks. . .
How Can I Display Error Messages in More Than One Way?
Changing the values in the StripesResources.properties file sets
the display of error messages for the whole application. We
can override these settings in a page by nesting the <s:errors-
header>, <s:individual-error>, and <s:errors-footer> tags within
<s:errors>:
<s:errors>
<s:errors-header> code for header goes here </s:errors-header>
code before each message goes here
<s:individual-error/>
code after each message goes here
<s:errors-footer> code for footer goes here </s:errors-footer>
</s:errors>
For example, if we wanted to keep the Stripes defaults in Stripes-
Resources.properties and use the error box just for the contact
form,
we
would
have
replaced
the
<s:errors/>
tag
in
con-
tact_form.jsp with this:
<s:errors>
<s:errors-header>
<div class="errors">
<img src="images/error.gif"/>
</s:errors-header>
<p>
<s:individual-error/>
</p>
<s:errors-footer>
</div>
</s:errors-footer>
</s:errors>
We can customize field-specific error messages in the same
way—just specify the field= attribute in the <s:errors> tag.
This gives us the possibility of having the most-often used error
message display configured in StripesResources.properties and still
have as many different ways of displaying error messages as we
need.
 
Search WWH ::




Custom Search