This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Costom validator with domain object

 
Shaiju scientia
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have domain object Emloyee and through a UI the user enters the values for this domain object.
I want to validate the values entered by the user.
Now the scenario is , i wan to validate a particular attribute based on another attribute of the same domain object.
say I have a boolean attribute "isAvailable" in my domain object, this is set by the user by selecting check box .
Now I want to validate another attribute called "salary" based on the attribute "isAvailable" .

Any Idea how, can I achieve this.

My design is like this

1) Create a custom validater
2) Define an attribute Employ emp in the custom validater (Not sure whether this is right)
3)implement validate method and use the emp object to performe the validation

But problem is step 2 outsource. Is there a way I can inject the object into the validater?
Can anybody suggest ?

Thanks in Advance
Shaiju
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did something similar when I did a password double-check validator. I couldn't inject, but I did make the validator look for the named pair control by searching the JSF object tree inside the validation method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic