• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No validation before LookupDispatchAction

 
Tim Storms
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm creating some kind of wizard with struts. On most of the pages, there should be a Back and a Next button. I'm using LookupDispatchAction classes to acheive that.

Obviously when somebody clicks the back button, the previous page should be shown. Validation of the current form is therefore not nessecary. The problem is that the form bean is being validated (nessecary when the next button is clicked). Is there some kind of way I can disable the validation when the back button is clicked?
 
Dileep Kamath
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set validate="false" in the struts-config and do a explicit call to the validate method of the form based on the required criteria.
 
Tim Storms
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I tried that, but if I'm not mistaken, I have to change form automatic xml validation to manual validation in the validate method of my form bean?! Correct me if I'm wrong. Is there a way to be able to keep on using automatic validation? I'm having a lot of forms (40+) so changing the validation type would be a lot of work.
 
Dileep Kamath
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A call to validate method of the ValidatorForm would invoke the validations defined in the xmls, so you wouldn't need to do anything specific to a form to invoke the validations.
 
Tim Storms
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok nice, it works.

In my LookupDispatchAction class, I've written the following code (I left a piece out):

Is there even an easier way to do this, or does this piece of code seems to be fine?

Also, the saveErrors method is deprecated. Can I use another method or do I have to live with it?

Thx...
 
Dileep Kamath
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, thats the way it works...

Struts 1.2 has introduced

to replace


ActionErrors extends ActionMessages so you should be ok. If you want to remove any warnings then just typecast errors to ActionMessages
 
Tim Storms
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your information! I was able to implement it successfully.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic