aspose file tools*
The moose likes Struts and the fly likes struts validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts validation" Watch "struts validation" New topic
Author

struts validation

Bhaskar Reddy
Ranch Hand

Joined: Dec 17, 2002
Posts: 52
Hi Folks,

I am currently using ValidatorForm for my validations. Since most of the validations are available in the struts provided default validations, I am making use of the same.
However, I'd like to highlight (in red) the form field which is causing the validation to fail. How do I accomplish this? From the <html:errors>, is it possible to know which field(s) has caused the error?

Appreciate your assistance!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Use the <logic:messagesPresent> tag. If you specify a property attribute in this tag, the body will be executed only if there is an error message present for that field. Example:

[ July 09, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Bhaskar Reddy
Ranch Hand

Joined: Dec 17, 2002
Posts: 52
Sorry for the delayed reply!
I tried it just now as some other tasks took priority and this worked just great for me.

Thank you Merrill!!
Nyanas Kandhan
Ranch Hand

Joined: Jan 27, 2009
Posts: 35
For an example on Highlighting Error Fields you can refer here.

Struts Highlighting Error Fields

regards
Struts Developer


regards,
Nyanaskandhan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: struts validation