• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When to get basic/essential data while handling a request

 
Ari Kovak
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This concerns an existing Struts1 app.

I have a form field used to identify a data object. When my form fails to validate its execute is never run which results in the data object never getting loaded. In many JSP's I want the data object's title and other information, which I can't access if my form validates with errors. Loading the data in the validate method feels wrong, but is it?

Currently the data is loaded in a parent "base" action class that is extended by many other actions. I was hoping there would be some kind of "init" method I could override (be it the Action or the ActionForm) that is always called regardless of validation.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There isn't, although you could implement a custom request processor.

Personally, back in the days of Struts 1, I *never* used the automatic validation. I always had a base action class that had pre- and post-validation methods etc. and just called the validation manually--much more versatile, and it'd still use declarative validation by calling super. (Um, or the form's validate method, or something; I don't really remember.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic