wood burning stoves
The moose likes Struts and the fly likes validWhen help!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validWhen help!!" Watch "validWhen help!!" New topic

validWhen help!!

sweta naidu

Joined: Nov 02, 2004
Posts: 25
I have a situation to use valid when/requiredif.When number of years at address is less than 2 yrs i have to validate previous address.

This is the entry i have in validation.xml

<field property="prevAddressLine1" depends="required, requiredif">
<arg0 key="situation.streetAddress"/>
<arg1 key="situation.streetAddress"/>
<var-value>((numYrsAtAddr != " Less Than 24 Months"))</var-value>

prevAddressLine1 refers to form2 and numYrsAtAddr refers to form1. Is there any way i can do this??
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
When you want to create your own validation rules, then you can use apache's common-validation project. common-validation jar already comes with your struts.

The advantage which validation rules give is that you can reuse same rule for different form on fly without rewriting sam logic again and it promotes reusability.

Thing which is not clear

When number of years at address is less than 2 yrs i have to validate previous address.

When the entered value of someTextField is less than 2 yrs, then you want to trigger some validation routine and want to show error message.

Is it your problem?


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
I agree. Here's the link: http://aspose.com/file-tools
subject: validWhen help!!
It's not a secret anymore!