This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply 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: 55
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: 55
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Struts 2 - Client Side Validation - Date validation - Dynamic min max date
 
Similar Threads
short-circuit attribute not working in validation file
Adding more than one validation to form field
Struts2 very simple validation doesn't work
Struts 2 Validation
Struts 2 Integer Validation not working