hi there, only way i know for achieving this is to extend struts' tags and either override the getStyleClass() method or add a new property getErrorStyleClass().
if you search archives on this list, http://www.mail-archive.com/[EMAIL PROTECTED]/msg96068.html Niall suggested a few days back about his ErrorTextTag or TextErrorTag that basically overrides the getStyleClass() method. That in my opinion is the easiest way to go about this change. he also did point In one of my recent projects, I had to add errorStyleClass property to about 4 struts tags, and it is not pretty! I think BaseHandlerTag in struts need some real refactoring! hope this helps. ATTA ----- Original Message ----- From: "Joao Batistella" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Thursday, March 18, 2004 4:25 AM Subject: RE: Way tho highlight error form field But, how about server side errors that I can't not validate in Javascript? I tought about something like this: <html:text property="test" styleClass="normal_class" styleClassOnError="error_class"/> So, if I return an ActionError about the property test, the style class to use would be error_class, otherwise, normal_class. I know this doesn't exist in Struts but is there something that can do something like this? Thanks -----Original Message----- From: Mark Lowe [mailto:[EMAIL PROTECTED] Sent: quinta-feira, 18 de março de 2004 10:06 To: Struts Users Mailing List Subject: Re: Way tho highlight error form field You could modify the client-side validation stuff to do this rather than just alerting. An easy way of layering this on is to define a compulsory array of fields and then loop through the form on validation. changing the borderColor style attribute when you have a match between the element name and your array. compulsary = ["name","email"]; function validate(form) { for(i = 0;i < compulsary.length;i++) { field = compulsary[i]; value = form.elements[field].value; if(value == "") { form.elements[field].style.borderColor = "#ff0000"; } } } Then you can think about having your compulsary array populated in the same way as the struts validator client-side stuff. In fact you could use the array then it defines. On 18 Mar 2004, at 10:49, Joao Batistella wrote: > Hello! > > Is there a way in Struts to highlight the HTML form field that has an > error? > I mean, changing the style class of the form field, for example. Is > there > some feature in Struts that can help me? > > Thanks, > JP --------------------------------------------------------------------- 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]