Customize Validation Error Message In Jsf 2.0
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to customize JSF validation error message up vote 14 down vote favorite 3 How can I customize the validation message that appears when validation fails? Here is the code I have:
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to set a custom message for a standard validator in JSF? http://stackoverflow.com/questions/10411773/how-to-customize-jsf-validation-error-message up vote 6 down vote favorite 4 I created a simple input field for an int variable. I want to add validation to it but, but i see no need to create my own validator for it, since the only thing i need is to avoid negative values and characters other than numbers. So this is what i did:
http://stackoverflow.com/questions/6250685/how-to-set-a-custom-message-for-a-standard-validator-in-jsf
New Topic programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums Forum: JSF JSF validation messages ... how to customize ? Alex Nedelcu Greenhorn Posts: 15 https://coderanch.com/t/211313/JSF/java/JSF-validation-messages-customize posted 10 years ago Hi, I'm still learning JSF ... sorry for such a newbie question. When having validators on fields, how can I customize the error messages, but for each field in particular. I know about overwritting javax.faces.component.UIInput.REQUIRED, but I don't want my message to sound so general, like `Validation Error: Value is required`. I want my error message to be customized for each field, like: Username is required Password is required Please repeat customize validation password Alex Nedelcu Greenhorn Posts: 15 posted 10 years ago Unfortunately I found that the answer is not so beginner-friendly. According to this article http://www.oracle.com/technology/pub/articles/masterj2ee/j2ee_wk7.html one can customize these error messages by implementing a phase listener. I'm a little dissapointed. Another hack like this for such a simple thing, and I'll dismiss JSF completely, although I do feel a relief that at least it is possible. Jeff Albertson Ranch Hand Posts: 1780 customize validation error posted 10 years ago Hi Alex, I'd be interested in seeing how others do this but this is my approach: 1. Instead of using required="true" (because I don't know how to override that bit of behaviour), I wrote a custom converter: