This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Is there any way to add customised error messages when using Standard Converters and Validators in JSF. I actually have to use DateTimeConverter adn NumberConverter provided by JSF, but still it does not allow me to add customised error messages instead of Standard messages like Converter Exception or Validator Exception.
Although, JSF simplifies a great deal to create Custom Converters and Validators, still I have to create my own DateTime and NumberConverter and Validators just for simply displaying customised errors.
Moreover is there a way in JSF to handle our own Exception Handling as done in Struts so that we can throw Application level Exceptions instead of Standard Exceptions.
I am really looking for some useful inputs from you...
Welcome to JavaRanch! We have very few rules around here but one that we're kind of particular about is the JavaRanch Naming Policy. Please take a moment to review it and then change your profile real quick so that your publicly displayed name complies. We also don't want you to miss out on a chance to win the book in the week's promotion since only ranchers with valid names are eligible for the contest.
Well, what we have done to overcome this is created a custom validator and inside the validate method you can get the component Id of the component using the method : "component.getClientId()" and then pick up the message from the resource bundle corresponding to this id.
You can also pass the arguement (like format pattern etc.) to the properties file.
But I am not sure if this can be implemented in the Validator provided by JSF, I guess you need to create a custom one for yours.
Joined: Dec 14, 2004
But still can we do this through properties file where we can just identify the component id by using <h:message for="amount"/> for id "amount" and getting the error message corresponding to this id from the properties file.