This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes Custom error messages in JSF validators? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Custom error messages in JSF validators?" Watch "Custom error messages in JSF validators?" New topic
Author

Custom error messages in JSF validators?

Namitha karupaiya
Ranch Hand

Joined: Mar 10, 2004
Posts: 89
How can I put my custom error messages for JSF built-in validators?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

You normally specify the validation message as the text of the ValidationException thrown by the validator. However, you can override this on the validator tag itself and display whatever text you want to for the element being validated.


Customer surveys are for companies who didn't pay proper attention to begin with.
Namitha karupaiya
Ranch Hand

Joined: Mar 10, 2004
Posts: 89
Is it possible to override the error message from a built-in validator (ex: valueRequired validator) globally? That means if I make some changes in the web.xml or faces-config.xml, I will have my custom message for this validator in all my JSF pages.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

The "required=" attribute is a special case, since it's built into tags instead of applied as a sub-element. Yes, you can override this message.

I don't remember the details, but I think they're pretty easy to dig up. The same mechanism also permits overriding the more conventional (element-defined) standard validators.
suresh dasari
Ranch Hand

Joined: Oct 05, 2009
Posts: 121

use the following code in faces-config.xml file and write your own properties file with name xxxxxxMessages.properties
but make sure to use the same error code/Id for user defined property file and give whatever the description you want.



Sun Certified Java Programmer with 93 percent
Namitha karupaiya
Ranch Hand

Joined: Mar 10, 2004
Posts: 89
Thanks suresh dasari !

Where should I place this xxxxxxMessages.properties file in my project?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom error messages in JSF validators?
 
Similar Threads
JSF 2.0 cannot rech out-come page
Displaying component id for error message
Passing parameters/ attributes to a custom validator
To Authors - Exception Handling in JSF
display error message