aspose file tools*
The moose likes Struts and the fly likes compare the date field with the current date in struts 2 validation.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "compare the date field with the current date in struts 2 validation.xml" Watch "compare the date field with the current date in struts 2 validation.xml" New topic
Author

compare the date field with the current date in struts 2 validation.xml

vydehi vajanapally
Greenhorn

Joined: Mar 02, 2009
Posts: 9
hi, i want to compare the date field with the current date. for that i need current date into the validation.xml file so that i can compare it how can i implement it i m using struts2. how can we compare in validation.xml??
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Using OGNL, but to be honest, I'd do this in a validate() method. Anything beyond the most simple stuff I take out of XML configuration.

You could also write a custom validator.
vydehi vajanapally
Greenhorn

Joined: Mar 02, 2009
Posts: 9
Thanks for the update.
May i know the advantage of using validate() instead of validation.xml

one more question-- we can do server side validations in 3 ways right,
1) using annotations
2) using validate()
3) using validation.xml

Which one will take high precendence if i am doing the validations in all the above ways for the same field/ form element.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

vydehi vajanapally wrote:May i know the advantage of using validate() instead of validation.xml

Easier unit testing and re-use.
Which one will take high precendence if i am doing the validations in all the above ways for the same field/ form element.

Honestly, I don't remember... I *think* it's XML, annotations, then validate, but could be completely wrong--it'd be easier to just test.
Jay Nalinbhai Patel
Greenhorn

Joined: Mar 29, 2011
Posts: 1

The precedence is
Validation.xml
annotations
validate()
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compare the date field with the current date in struts 2 validation.xml