Thanks Niall, I will give it a try, it sounds good :) what about other
HTML input component? Is it doable the same way?

Erez

-----Original Message-----
From: Niall Pemberton [mailto:[EMAIL PROTECTED] 
Sent: Saturday, March 13, 2004 12:54 AM
To: Struts Users Mailing List
Subject: Re: best way to highlight error form fields

I have done this by extending the struts <html:text> tag and using the
stylesheets - its pretty straight forward.

I overrode the getStyleClass() method to do the following:

1) Retrieve the "ActionErrors" from the request
2) Check if there is an error message for the name/property
3) If there is an error - append a suffix to the StyleClass attribute
("Err"
by default")

So I have something like:

   <myTagLib:text  property="somethingOrOther" styleClass="fieldStyle"/>

If "somethingOrOther" is VALID it generates:
   <input type="text" class="fieldStyle" ..../>

If "somethingOrOther" is INVALID it generates:
   <input type="text" class="fieldStyleErr" ..../>

All you have to do is set up two styles in your style sheet, the error
style
with an appropriate color.

I have put the source code on my web site:

        http://www.niallp.pwp.blueyonder.co.uk

Niall


----- Original Message ----- 
From: "Erez Efrati" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Friday, March 12, 2004 9:48 PM
Subject: best way to highlight error form fields


> Hi all,
>
> I have a form and I am searching for the best way to do the following:
> 1. In case there were errors found in the form fields, highlight those
> fields (using background color of red for example).
> 2. If there are more than 4 fields with errors, show the user one
> compact error saying that he should enter the highlighted fields.
>
> One way I came up with is using <logic:messagePresent> tag for each
> field and changing the style he's using thus highlighting it. Is there
a
> JSTL equivalent way to perform this?
>
> Thanks in advance,
>
> Erez E
>
>
>
>



---------------------------------------------------------------------
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