Here's something from the archives you might find useful.

---------------------------------
Since this is essentially error text you are talking about, I think the
easiest way to handle this is through Struts's error tags:

<html:text property="username" ... /> <html:errors property="username"/>

Where there is an error on "username," you add a new ActionError with a
message key like "error.field.icon" or something, and the value of that key
is just HTML that generates the icon.

So you would have this in your ApplicationResources.properties file:

error.field.icon=<img src="error_icon.gif" />

The drawback then is that you really can't add any other errors on
"username" or else the display would mess up.

We used this approach on a project and it worked well.


Sean
---------------------------------

> -----Original Message-----
> From: Michael Hanisch [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 14, 2003 9:05 AM
> To: Struts Users Mailing List
> Subject: Re: Highlighting fields that failed in validation
> 
> 
> On Fri, 2003-02-14 at 13:37, O'Hara, Jean wrote:
> > Hi there
> > 
> > A requirement for the application I'm working on is to 
> highlight fields that
> > cause validation errors in red and also display an asterisk after the
> > offending field.  This is as well as giving a list of the 
> errors in a box to
> > the side.  Listing the errors in the box is fine but does 
> anyone know of a
> > good way of highlighting each field.  I'm using the Struts Validator
> > framework and using the DynaValidatorForm.  I think I might 
> need to write
> > some custom tags but am not very familiar with custom JSP tags. 
>  Any advice
> > would be welcome!
> Umm... not sure what you mean by "highlight".
> What I usually do is to render every form widget in a table cell of its
> own; if there is an error for a widget, "highlight" this table cell in
> yellow (or whatever).
> 
> You don't necessarily need a custom tag for that, though it would make
> things easier. Otherwise, just use one of the logic tags to check if an
> error for the widget is present (logic:present or something like that).
> 
> HTH,
>       Michael.
> 
> 
> -- 
> Michael Hanisch                                      [EMAIL PROTECTED]
> Red Hat - RH Interchange Inc., Orleansstrasse 4,  D-81669 Munich/Germany
> phone: +49 (0)89 206058-53                      fax: +49 (0)89 206058-88
> 
> 
> ---------------------------------------------------------------------
> 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