-->
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: Using strings from resource bundle in pattern validator
PostPosted: Sun Sep 19, 2010 2:45 pm 
Newbie

Joined: Sun Sep 19, 2010 2:17 pm
Posts: 2
Sorry if this is a simple question...
Is it possible to use strings from resource bundles in the regex of the @Pattern validator? Maybe using EL
e.g.
@Pattern(regex = "#{mypatterns.myregex}")

And what about the message attribute?
Thank you!

I forgot to say that I'm trying to use this validation in an JSF2 form and an bean injected with CDI.


Top
 Profile  
 
 Post subject: Re: Using strings from resource bundle in pattern validator
PostPosted: Mon Sep 20, 2010 5:07 am 
Hibernate Team
Hibernate Team

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

the regex cannot be read from the resource bundle. To implement this you would have to write your own ConstraintValidator implementation for the Pattern constraint and configure it in an xml configuration file.
Why do you try to place your patterns into a resource bundle? Do you really have Locale depended patterns?

--Hardy


Top
 Profile  
 
 Post subject: Re: Using strings from resource bundle in pattern validator
PostPosted: Thu Sep 23, 2010 1:04 am 
Newbie

Joined: Sun Sep 19, 2010 2:17 pm
Posts: 2
bad news...

Yeah, I have some constraints that depends on user's locale. So, my only option is to create my own validator.

Thank you!


Top
 Profile  
 
 Post subject: Re: Using strings from resource bundle in pattern validator
PostPosted: Thu Sep 23, 2010 3:57 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
You just need you own ConstraintValidator<Pattern, String> implementation. Should be straight forward.


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.