-
1. Re: Internationalized hibernate validator messages
jpaagt Sep 23, 2005 4:08 PM (in response to hookomjj)Thank you for your fast response.
The idea of using hibernate validator is to define validation in one place and one place only, so that you don't replicate this througout your application. It would be a shame that the Hibernate Validator framework could not be used to validate the user input data because the framework cannot render an internationalized message. Using JSF validation in JSPs would be a solution, but, that "cool" feature (defining validation in one place) would be lost... which in my opinion makes Seam loose a great feature. JSF validation and data validation would have to be synchronized every time data constraints are changed, which is more vulnerable to error. I don't know if I'm asking to much of the framework... -
2. Re: Internationalized hibernate validator messages
hookomjj Sep 23, 2005 4:34 PM (in response to hookomjj)"jpaagt" wrote:
Thank you for your fast response.
The idea of using hibernate validator is to define validation in one place and one place only, so that you don't replicate this througout your application. It would be a shame that the Hibernate Validator framework could not be used to validate the user input data because the framework cannot render an internationalized message. Using JSF validation in JSPs would be a solution, but, that "cool" feature (defining validation in one place) would be lost... which in my opinion makes Seam loose a great feature. JSF validation and data validation would have to be synchronized every time data constraints are changed, which is more vulnerable to error. I don't know if I'm asking to much of the framework...
What you are stating makes total sense. The JSF spec had to go through the same growing pains into JSF 1.2 for handling customized messages. I would go ahead and use the JIRA issue tracker to post your ideas on how best to express this customization.
-- Jacob Hookom -
3. Re: Internationalized hibernate validator messages
gavin.king Sep 24, 2005 10:16 AM (in response to hookomjj)Hibernate Validator supports internationalization.
Check the documentation for Hibernate Validator to see how to include text from a resource bunde in the error message. -
4. Re: Internationalized hibernate validator messages
jpaagt Sep 24, 2005 11:55 AM (in response to hookomjj)Hibernate Validator does have a mechanism to internationalize messages. From what I could see it uses the class ClassValidator to validate an object. ClassValidator has three constructors, two of which are mentioned in the documentation:
ClassValidator(Class)
andClassValidator(Class, ResourceBundle)
as stated in the section 3.2.3 Application-level validation.
However, JBoss Seam only uses the first constructor that recieves only a class. The class validator is created in class org.jboss.seam.Component in the constructor as follows:validator = new ClassValidator(beanClass);
(line 153).
However, I'v another more preocupating question bugging me. Should html forms (or user input in general) be validated using Hibernate Validator? Not all forms map one on one with an Entity Bean. So is this feature really useful?. If it is for some cases, how coherent would it be to use Faces validation and Hibernate validation in the same app?... -
5. Re: Internationalized hibernate validator messages
gavin.king Sep 24, 2005 1:48 PM (in response to hookomjj)You can use Hibernate Validator for things that are not entities. Actually, most form fields of most forms map directly to an attribute of an entity. But those that don't can still be handled by HV.
I'll add an issue to JIRA to allow a resource bundle to be used. -
6. Re: Internationalized hibernate validator messages
gavin.king Oct 7, 2005 5:29 AM (in response to hookomjj)Fixed in CVS, you can now put messages in
validator_en.properties
validator_de.properties
etc -
7. Re: Internationalized hibernate validator messages
mirko27 Mar 18, 2006 9:58 AM (in response to hookomjj)So now we should create validation messages through Seam?
Or what? And where to put them? any dependencies on names?
Seam is still very poorly documented:( -
8. Re: Internationalized hibernate validator messages JBSEAM-86
nhpvti Aug 24, 2006 12:18 PM (in response to hookomjj)Hi,
JBSEAM-86 issue states that the issue has been fixed. Bu it doesn't work for me in JBoss-Seam 1.0.1.GA
server.log has e.g. such lines:
DEBUG [org.hibernate.validator.ClassValidator] ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages
Application shows for the booking example e.g. #"creditCard": Eingabe erforderlich#.
But DefaultValidatorMessages_de.properties in \jboss-4.0.4.GA\server\default\lib\hibernate-annotations.jar\org\hibernate\validator\resources\
has the following entry:
validator.notNull=kann nicht leer sein
Where does the text #"creditCard": Eingabe erforderlich# comes from and how it can be replaced by a customized one?
Thank you in advance for any tip -
9. Re: Internationalized hibernate validator messages
nhpvti Aug 24, 2006 12:23 PM (in response to hookomjj)Additional info:
I've placed
validator.properties
validator_en.properties
validator_de.properties
into
\jboss-seam-1.0.1.GA\examples\booking\resources\WEB-INF\classes
But they are ignored -
10. Re: Internationalized hibernate validator messages JBSEAM-86
nhpvti Sep 4, 2006 10:49 AM (in response to hookomjj)"nhpvti" wrote:
Hi,
JBSEAM-86 issue states that the issue has been fixed. Bu it doesn't work for me in JBoss-Seam 1.0.1.GA
My error was placing ValidatorMessages properties files in WEB-INF/classes directory. They shoul be placed at the root of the EAR file.
See discussion on the same topic in the following thread
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=88798 -
11. Properties file and subdirectories?
bm97 Jan 8, 2008 8:36 AM (in response to hookomjj)Hi,
i use hibernate validator to annotate and validate the domain model. After searching in this forum i found no real solution to the question "where to put the ValidatorMessages.properties file".
I wrote several own validators so i had to introduce such a resource bundle. I put the file into src/main/resources (default maven structure). In this situation the file is found by hibernate validator. But i don't want to "pollute" the root-directory of src/main/resources with localization files, so i put them in a sub directory. In this situation the properties file is not found anymore.
How can hibernate validator find the file located in a subdirectory (without touching the original jar file)?
Any remarks?
Thanks in advance, Ben -
12. Re: Internationalized hibernate validator messages
pmuir Jan 9, 2008 7:10 PM (in response to hookomjj)It can't, it's hard coded to ValidatorMessages.properties.
BUT, Seam uses the Seam resource bundle as the message bundle for Hibernate Validator, which does allow you to place resource files where ever you like.