aspose file tools*
The moose likes Struts and the fly likes Validation three dependent fields using validwhen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validation three dependent fields using validwhen" Watch "Validation three dependent fields using validwhen" New topic
Author

Validation three dependent fields using validwhen

Ran Giri
Greenhorn

Joined: Oct 09, 2004
Posts: 7
I have three dependent fields, with the following condition. I am trying to do it using validwhen, but not able to satisfy all the conditions listed here... Any help is really appreciated.

Condition::::
If (1st contact ==null & 2nd contact ==null & 3rd contact==null)then please select atleast one.
Else if(1st=null && 2nd !=null && 3rd !=null) then 2nd != 3rd
Else if(2st=null && 1st !=null && 3rd !=null) then1st != 3rd
Else if(3rd =null && 1st !=null && 2nd !=null) then 1st != 2nd
Else if (1st !=null &&2nd!=null &&3rd!=null)then
(1st != 2nd && 2nd != 3rd && 3rd != 1st)
[ June 09, 2006: Message edited by: Ranjani Giri ]
Durgaprasad Guduguntla
Ranch Hand

Joined: Oct 20, 2003
Posts: 99
You will have other two options:
1. You can override the validate() method of your form. The super.validate() method call kicks in first and validates the fields as per the configurations in the validation.xml. Then you can fetch the values of those particular fields and validate them within validate method. Following is the code snippet:


2. You can write a CustomValidator. Declare this custom validator for the third field. You can fetch the values of the all the associated fields within the custom validator and add throw error messages.


Hope this helps.


Thanks,<br />Durgaprasad<br />SCJP1.4, SCWCD1.4, SCBCD1.3,<br />SCEA
Ran Giri
Greenhorn

Joined: Oct 09, 2004
Posts: 7
I cannot use action forms validate method, as I would lose the consistancy of developement. I was thinking to use Validwhen- The expression just bloats and gets confusing.. Any sudgestion on this really appreciated!!!

Thanks
Ran Giri
Greenhorn

Joined: Oct 09, 2004
Posts: 7
Thanks Very much. I really appreciate your help. I have the custom validation working.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validation three dependent fields using validwhen