-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Validator : {value} not replaced
PostPosted: Wed Dec 02, 2009 1:03 am 
Newbie

Joined: Wed Sep 09, 2009 1:17 am
Posts: 4
Hello,
Everything works fine with my Hibernate (and javax) validation, except that the {value} is not replaced in messages.
Here is the way I do:
Code:
MessageInterpolator messageInterpolator = Validation.buildDefaultValidatorFactory().getMessageInterpolator();
LOG.debug("- messageTemplate: " + violation.getMessageTemplate());
LOG.debug("- constraintDescriptor: " + violation.getConstraintDescriptor());
LOG.debug("- invalidValue: " + violation.getInvalidValue());
LOG.debug("- message: " + messageInterpolator.interpolate(violation
      .getMessageTemplate(), new Context() {
   @Override
   public ConstraintDescriptor<?> getConstraintDescriptor() {
      return violation.getConstraintDescriptor();
   }

   @Override
   public Object getValidatedValue() {
      return violation.getInvalidValue();
   }
}, locale));
Quote:
- messageTemplate: {org.hibernate.validator.constraints.Range.message}
- constraintDescriptor: ConstraintDescriptorImpl{annotation=org.hibernate.validator.constraints.Range, payloads=[], hasComposingConstraints=false, isReportAsSingleInvalidConstraint=true, elementType=FIELD, definedOn=DEFINED_LOCALLY, groups=[interface javax.validation.groups.Default], attributes={message={org.hibernate.validator.constraints.Range.message}, min=0, payload=[Ljava.lang.Class;@965654, max=90, groups=[Ljava.lang.Class;@1fdd342}}
- invalidValue: 99
- message: {value} doit être entre 0 et 90

What is the problem with my code?
Thanks!


Top
 Profile  
 
 Post subject: Re: Validator : {value} not replaced
PostPosted: Wed Dec 02, 2009 7:08 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
I am assuming you are using Validator 4.0.1.GA. You should update to 4.0.2.GA. The constraints Range and Email had wrong message tamplates. {value} does not exist as message parameter. Have a look at HV-268.

--Hardy


Top
 Profile  
 
 Post subject: Re: Validator : {value} not replaced
PostPosted: Wed Dec 02, 2009 6:00 pm 
Newbie

Joined: Wed Sep 09, 2009 1:17 am
Posts: 4
Excellent! It fixed my problem.
I don't know where and how to report this: the French message for @Email should be replaced by "Adresse email mal formée".
Thank you.


Top
 Profile  
 
 Post subject: Re: Validator : {value} not replaced
PostPosted: Wed Dec 02, 2009 6:18 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

Issues should be reported in Hibernate's Jira instance: http://opensource.atlassian.com/project ... /browse/HV

I created an issue for updating the resource bundle for you - HV-275. Thanks a lot for pointing this out.

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.