-->
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.  [ 3 posts ] 
Author Message
 Post subject: [Validator] Related field validation
PostPosted: Mon Nov 03, 2008 4:56 am 
Newbie

Joined: Mon Nov 03, 2008 4:36 am
Posts: 2
Location: Madrid, Spain
Hi.

I would like to know if is possible to access the object instance of the bean that contains the value attribute you are validating.

Example:

Code:
class Issue {

    private Date initDate;
    private Date endDate;

    ...
}


I whant to do a validator that checks that 'endDate' is after 'initDate', so in the validator of 'endDate' I need access the 'Issue' instance.

Is this possible?
How?

(I see in the source code that validator framework know the object instance, but I don't know if I can access to it from my validator class)


Thanks a lot
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2008 11:22 am 
Hibernate Team
Hibernate Team

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

in this case you should probably write a bean level validator. Have a look at the online documentation.

There is also an example in the test cases for validator using the classes
Vase, SerializabilityValidator and Serializability.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 04, 2008 12:13 pm 
Newbie

Joined: Mon Nov 03, 2008 4:36 am
Posts: 2
Location: Madrid, Spain
Ok, thanks

It's just what I need.

It's true it is in the documentation, in section 1.4: "you can write a Bean level validation annotation". But I didn's see ooops :S

Sorry for my silly question :P


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