wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts 2 - Client Side Validation - Date validation - Dynamic min max date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 - Client Side Validation - Date validation - Dynamic min max date" Watch "Struts 2 - Client Side Validation - Date validation - Dynamic min max date" New topic
Author

Struts 2 - Client Side Validation - Date validation - Dynamic min max date

Santhosh Kalisamy
Ranch Hand

Joined: Apr 15, 2008
Posts: 56
Friends,

In my application, we do retrieving a date from a JSP page.

code sniper for JSP:


InitialSwitchAction--Validation.xml


The effective Date field should be within 1 year before today and 1 year after today.

How do I define that dynamic value on "min" and "max" ?

Please help me. I want to check the possibility before I override validate() method to do that validation?!
nir sharma
Ranch Hand

Joined: Sep 11, 2012
Posts: 72



and you need to create getter and setter for minDate and maxDate in your corresponding action class, and assign the values using system date.
Santhosh Kalisamy
Ranch Hand

Joined: Apr 15, 2008
Posts: 56
Thanks Nir Sharma, It is a nice idea.

I have implemented this with slightly different idea. Created a custom Date Validator and fixed this with on validation side itself.



validators.xml


<actionclassname>-validation.xml


Thanks all.
 
jQuery in Action, 2nd edition
 
subject: Struts 2 - Client Side Validation - Date validation - Dynamic min max date
 
Similar Threads
short-circuit attribute not working in validation file
Struts 2 Validation
Struts2 very simple validation doesn't work
Adding more than one validation to form field
Struts 2 Integer Validation not working