[hibernate-issues] [Hibernate-JIRA] Updated: (ANN-458) Hibernate Validator initialization always requires keys in ValidatorMessges.properties

Emmanuel Bernard (JIRA) noreply at atlassian.com
Fri Oct 20 12:34:04 EDT 2006


     [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-458?page=all ]

Emmanuel Bernard updated ANN-458:
---------------------------------

    Component: validator
                   (was: binder)

> Hibernate Validator initialization always requires keys in ValidatorMessges.properties
> --------------------------------------------------------------------------------------
>
>          Key: ANN-458
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-458
>      Project: Hibernate Annotations
>         Type: Bug

>   Components: validator
>     Versions: 3.2.0.ga
>     Reporter: Christian Bauer
>     Assignee: Emmanuel Bernard
>     Priority: Blocker
>      Fix For: 3.2.1

>
>
> Seam + Hibernate Validator doesn't work. When AnnotationConfiguration boots, it always uses the DefaultMessageInterpolator (this is actually a separate problem, not only the event listeners should use the configured interpolator) and the default interpolator always throws an exception if the message key can't be found.
> This is an even bigger problem if you don't want or have a ValidatorMessages.properties file, like in a typical Seam application where everything is in messages.properties (Seam managed component). You can't override or set the resource bundle that is used on startup.
> A quick fix would be to not throw an exception in DefaultMessageInterpolator if the key can't be found in the resource bundle. The key should then be returned as the message. I see no reason why that shouldn't work, it's the users own fault if he forgot the key. It's also the regular behavior in JSF.
> This is my quick hack to make it work, in DefaultMessageInterpolator:
> 					String string = null;
> 					try {
> 						string = messageBundle != null ? messageBundle.getString( token ) : null;
> 					}
> 					catch( MissingResourceException e ) {
> 						//give a second chance with the default resource bundle
> 					}
> 					if (string == null) {
> 						try {
> 							string = defaultMessageBundle.getString( token );
> 						}
> 						catch( MissingResourceException e) {
>                             return message;
>                             /* We don't want that:
>                             throw new MissingResourceException(
> 									"Can't find resource in validator bundles, key " + token,
> 									defaultMessageBundle.getClass().getName(),
> 									token
> 							);
> 							*/
> 						}
> 					}
> I'm writing now about this in the JPwH book, so I expect that I can in the future simply have messages.properties for Seam with my Hibernate Validator messages. This fix has to be in 3.2.1.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list