wood burning stoves 2.0*
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
Author

validWhen help!!

sweta naidu
Greenhorn

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>
<var-name>test</var-name>
<var-value>((numYrsAtAddr != " Less Than 24 Months"))</var-value>
</var>
</field>


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?



Naseem


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!!
 
Similar Threads
validation in tomcat 4.1
Help with validation rules for form with multiple submit buttons
Struts validation with minlength
problem in using validator framework with multiple screen jsps
Validate multiple fields base on a requiredif