Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts validation

 
Bhaskar Reddy
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bhaskar Reddy
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For an example on Highlighting Error Fields you can refer here.

Struts Highlighting Error Fields

regards
Struts Developer

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic