• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to highlight an inputText in JSF 2.0 when a validation error occurs  RSS feed

 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to highlight an inputText in JSF 2.0 when a server-side validation error occurs?
I have the server side validation,if validation fails, text box color (style) should change.
else it should display in normal color.
 
Tim Holloway
Bartender
Posts: 18713
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot do that using standard validation, because of the way that the built-in validation system works.

Whay you can do is turn off the built-in validation and do your own validation in an action method. If validation fails, you just bypass the business logic part of the action method code.

To control the color of the failing input, you can add a style or styleClass attribute to that control whose value is an EL expression returning styling information that's set to whatever styling you want for highlighting bad input.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!