check out logic:messagesPresent, it will do what you want for line item 2.

There is a good example of using this in the book Professional Struts.

I know... I wrote that example ;)

Rick Hightower
Developer

Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
Struts/J2EE consulting --
http://www.arc-mind.com/consulting.htm#StrutsMentoring

-----Original Message-----
From: Brown, James [mailto:[EMAIL PROTECTED]
Sent: Sunday, January 25, 2004 4:33 AM
To: Struts Users Mailing List (E-mail)
Subject: ActionErrors display


Hi,

I have been trying to work through the display of ActionErrors - both global
and non-global (field level) - such that it would look something like the
following HTML sample:

<html>
<head><title>Search Form</title></head>
<body>
  <P><strong>The following errors have occurred:</strong></P>
  <UL>
    <LI><i>A global error has been detected</i></LI>
    <LI><i>Last Name is invalid.</i></LI>
  </UL>
  <p>Fields marked with a red background and a <img
src="https://scgi.ebay.com/saw/pics/sitewide/warning_9x10.gif"; width="9"
height="10" hspace="3" vspace="2" border="0"><font face="Arial, Helvetica,
Verdana, sans-serif" size="2"> have failed validation.</p>
  <form name="search" method="POST" action="search.do">
  <h3>Please provide the following search criteria information.</h3>
  <p>You must complete all of the fields marked with an asterisk <font
color="red">(*)</font>.</p>
  <p><font color="red">*</font>Last Name:
    <input style="background: red" type="text" name="lastname"
maxlength="25" size="25" value="Do!" title="Last Name is invalid.">
      <img src="https://scgi.ebay.com/saw/pics/sitewide/warning_9x10.gif";
width="9" height="10" hspace="3" vspace="2" border="0"></p>
  <p><font color="red">*</font>First Name:
    <input type="text" name="firstname" maxlength="25" size="25"
value="John"></p>
  <input type="submit" value="Continue">
</body>
</html>

The desire is:
  1. All errors will appear in one place - the top of the page.
  2. Any field for which validation errors have been detected, would be
further flagged in 1 of three potential ways:
     a. changing the fields background colour;
     b. marking it with an exclamation icon (thanks to eBay for the quick
sample); or
     c. including the error message (in this case "Last Name is invalid.")
in the title attribute of the input.

#1 is easily achieved; however, I have been struggling with #2 in any form.
The html:errors tag makes it very easy to output the message for a specific
field, but I cannot seem to find a means to use it to "flag" that an error
has occurred.

Any suggestions would be greatly appreciated.

                                  Cheers,
                                  James

THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to