Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1 - Validate method being called before page load

 
bryan nelson
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
bryan nelson
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps I should clarify that I am using DispatchAction.
 
bryan nelson
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic