aspose file tools
The moose likes Struts and the fly likes Struts 1 - Validate method being called before page load Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Struts 1 - Validate method being called before page load" Watch "Struts 1 - Validate method being called before page load" New topic
Author

Struts 1 - Validate method being called before page load

bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Hello there,

My validate method seems to be being called before the page ever loads...meaning before the form is ever populated. I only need it to be called after the form is submitted. I believe there is some way to fix this but I have searched and cannot find it.

Any ideas?

Thank you!


"...and the Truth will set you free."
bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Perhaps I should clarify that I am using DispatchAction.
bryan nelson
Ranch Hand

Joined: Jun 16, 2003
Posts: 95
Apparently DispatchAction and the validate() method don't always play nicely together. You can do a search to find out the details of why this is...but here is a solution:

If you place the following check in your validate method you will be able to safely skip the first call to validate (on the initial form load) while still hitting the second call on form submission as intended.



Basically you're just checking to see whether or not your DispatchAction parameter has a value set to it yet. If it doesn't, it's the initial load. If it does, then it is actually the form submission.

Hope this helps someone!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Struts 1 - Validate method being called before page load
 
Similar Threads
Common JSP/Action displaying confirmation details
cewolf charts
Property value not getting set in Action Form
Better way to update a form with struts ?
Displaying error in multi page form.