• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validWhen help!!

 
sweta naidu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic