-->
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: Individual Messages for a @List of constraints?
PostPosted: Wed Mar 07, 2012 5:05 am 
Newbie

Joined: Wed Mar 07, 2012 4:48 am
Posts: 1
Hi,

I have a class-level annotation of a List of the same contraint, like this:
@IfFieldHasValueThenFilled.List(
{
@IfFieldHasValueThenFilled(field = "salutation", value = "company", mustBeFilled = "company"),
@IfFieldHasValueThenFilled(field = "salutation", value = "company", mustBeFilled = "ustIDNumber"),
@IfFieldHasValueThenFilled(field = "salutation", value = "company", mustBeFilled = "taxNumber",
})

The constraint gets validated as intended, with the message read from the key IfFieldHasValueThenFilled.myBeanName

However, I'd like to set individual messages for the 3 constraints of the list - e.g. if company is not filled, show a different message then when taxNumber is not filled.

Is that possible? If so, how?

I have tried setting a message with the individual constraints (like @IfFieldHasValueThenFilled(field = "salutation", value = "company", mustBeFilled = "company", message = "${companymessage}"), but it does not work, it always shows the message for the costraint annotation type.
(I use the validator in a spring mvc application, and use a custom class declared as a spring MessageSource)

Any help is much appreciated.

Elmar


Top
 Profile  
 
 Post subject: Re: Individual Messages for a @List of constraints?
PostPosted: Thu Mar 08, 2012 7:01 am 
Hibernate Team
Hibernate Team

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

could you complete your example with the implementation of IfFieldHasValueThenFilled and how you use it. Also which message exactly do you get? using the message parameter in each constraint is the right approach imo.

Maybe you can even create a testcase?

--Hardy


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.