There are two ways to do this - 1) Modify the struts-html.tld (which is usually deployed in WEB-INF) and change the class name of the "text" tag, The downside is that, if you upgrade to a new version of struts, you have to remember to re-apply the change.
2) Create a new tld for this tag - I've put a tld file up on my web site just for this tag, as well as a jar which contains the class and source files. http://www.niallp.pwp.blueyonder.co.uk Niall ----- Original Message ----- From: "Erez Efrati" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Saturday, March 13, 2004 10:26 PM Subject: RE: best way to highlight error form fields > Sorry but this is quite new to me: how do you use this source code? How > I integrate it? Do I write a TLD file?? > > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]