-->
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] How to evaluate message template?
PostPosted: Wed Jul 12, 2017 1:41 pm 
Regular
Regular

Joined: Mon Aug 07, 2006 6:22 pm
Posts: 67
I'm attempting to write a Javadoc Taglet class that summarizes the constraints in a class.

When I'm processing a particular constraint that I found on a property, I can see the message template value, like "{javax.validation.constraints.Size.message}". In my code, how can I evaluate that template to get the actual text of the message?


Top
 Profile  
 
 Post subject: Re: [validator] How to evaluate message template?
PostPosted: Wed Jul 12, 2017 2:26 pm 
Regular
Regular

Joined: Mon Aug 07, 2006 6:22 pm
Posts: 67
I suppose it might be something like this:
Code:
validatorFactory.getMessageInterpolator().interpolate(constraintDescriptor.getMessageTemplate(), context);


But I don't understand what to provide as the context. If I send null it gets a NPE.


Top
 Profile  
 
 Post subject: Re: [validator] How to evaluate message template?
PostPosted: Thu Jul 13, 2017 6:37 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi David, I've replied to your SO question (https://stackoverflow.com/questions/450 ... nstraint-d) -- you could try and pass in a simple dummy implementation of the context contract which just returns the constraint descriptor.

Hth,

--Gunnar

PS: Please avoid cross-posting here and on SO; we monitor both places, so posting to one is enough and less confusing :) Thanks!

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


Top
 Profile  
 
 Post subject: Re: [validator] How to evaluate message template?
PostPosted: Thu Jul 13, 2017 11:19 am 
Regular
Regular

Joined: Mon Aug 07, 2006 6:22 pm
Posts: 67
Thanks. That worked perfectly.

Now that I know you're about the only person who will reply on this topic :) , I won't cross-post.


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.