• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation in Struts 1.3.x

 
Aditya Keyal
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to know if I can use the commons-validation framework (validation.xml) and also the validator method (in Validator Form) both simultaneously. What I need is a situation where the basic validations pertaining to empty fields and the like are done in the validation.xml and business logic based validation are done in validator method. Currently I am doing the buisiness validation in the Action but wanted to make it neater. Thanks.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try a simple form validations using both Struts validation framework with overriding "validate()" method in validtor form and let us know after calling validation JavaScripts whether the "validate()" method gets called or not ?
 
Aditya Keyal
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have already tried that and only the validation.xml gets invoked. Struts bypasses the over-ridden validation method in form. Thats why I had to actually write the business validation in Action. I was wondering if there was some other way that can get the job done.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aditya Keyal wrote:I have already tried that and only the validation.xml gets invoked. Struts bypasses the over-ridden validation method in form.

Then you tried a wrong way or misconfigured something. Two things to look out for while making this kind of validation succeed:

  • Make you Action Forms of type ValidatorForm, means extends ValidatorForm
  • Make attribute "validate="true" in action mapping.


  • HTH
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic