-->
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.  [ 2 posts ] 
Author Message
 Post subject: jsr303 + jsf2 + annotation value as formatted msg parameter
PostPosted: Wed Jun 10, 2015 3:39 am 
Newbie

Joined: Sun Jan 29, 2006 10:11 am
Posts: 3
I have a question regarding something isnt working for me:

I have a custom annotation
validation works as expected

Code:
...
@MaxDouble(value=100.0)
private Double someAttributeName;
...



I have a message:

Code:
messages.properties
...
mykey1=... {value} ...
...


this works but prints 100.0 in the message
i want it formatted as currency


Code:
messages.properties
...
mykey1=... {value,number,currency} ...
...


this doesnt work it prints this in the message
... {value,number,currency} ...



hibernate.validator.version = 4.1.0.Final
com.sun.faces.jsf.version = 2.0.2
org.richfaces.version = 3.3.3.Final

jdk6 -> MessageFormat


according to jdk6 Messageformat it should work.


plz help
howto format it

my fallback idea is to:
in the validator override the message handling and


Top
 Profile  
 
 Post subject: Re: jsr303 + jsf2 + annotation value as formatted msg parameter
PostPosted: Thu Jun 11, 2015 5:03 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi,

MessageFormat syntax is not supported in Bean Validation Messages. As of Bean Validation 1.1 (Hibernate Validator 5.x), you can use java.util.Formatter-style formattings: http://docs.jboss.org/hibernate/validator/5.2/reference/en-US/html_single/#section-interpolation-with-message-expressions. If you are stuck on HV 4.x (I'd recommend to upgrade to the latest 4.3 at least, compared to 4.1 it has many bug fixes etc), you may achieve the same using a custom message interpolator implementation: http://docs.jboss.org/hibernate/validator/5.2/reference/en-US/html_single/#section-custom-message-interpolation

Hth,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.