Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
vydehi vajanapally
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
Chrome Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The precedence is
Validation.xml
annotations
validate()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic