[
http://opensource.atlassian.com/projects/hibernate/browse/ANN-458?page=co...
]
Christian Bauer commented on ANN-458:
-------------------------------------
"you should set string to token and also take the delimiters into account. "
What?
Hibernate Validator is the _only_ framework that would not let an i18n message key simply
pass through when it can't be found in the message resources. It makes no sense in
development, try to use it. Translation and message definition is usually a second step.
Try to use POT in any Unix software, or PHP software. They all let the key through.
My deployment should not fail everytime I forget a key. Worse, you currently have to
restart the whole appserver to reload a resource bundle (Seam will have a solutionf or
that soonish). This makes this behavior a total nightmare.
I absolutely expect that this will be fixed in 3.2.1 and that I will see a message key
when I forget to define a value for it.
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: binder
Versions: 3.2.0.ga
Reporter: Christian Bauer
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira