File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes No validation before LookupDispatchAction 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 "No validation before LookupDispatchAction" Watch "No validation before LookupDispatchAction" New topic
Author

No validation before LookupDispatchAction

Tim Storms
Ranch Hand

Joined: Apr 27, 2006
Posts: 64
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?


SCJP 1.5, SCWCD 1.4, SCBCD 5
Dileep Kamath
Greenhorn

Joined: Jul 15, 2006
Posts: 19
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

Joined: Apr 27, 2006
Posts: 64
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

Joined: Jul 15, 2006
Posts: 19
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

Joined: Apr 27, 2006
Posts: 64
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

Joined: Jul 15, 2006
Posts: 19
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

Joined: Apr 27, 2006
Posts: 64
Thanks for your information! I was able to implement it successfully.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No validation before LookupDispatchAction