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
posted Jul 01, 2010 06:26:09
0
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
posted Jul 01, 2010 11:44:48
0
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()
subject: compare the date field with the current date in struts 2 validation.xml