GeeCON Prague 2014*
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


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: 59
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: 59
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.
 
GeeCON Prague 2014
 
subject: Struts 2 - Client Side Validation - Date validation - Dynamic min max date