This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Santhosh Kalisamy
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
Eclipse IDE Java Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic