• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2: bypass the prepare method?

 
Raymond Holguin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok here is my scenario....
My Action class does the input() method and a save() method. the class also implements the Prepareable, and the prepare method is what i use to load up the drop down lists (or whatever other populated data i need for my form). When i call the input method or if validation fails then the prepare method gets called like i want it do and directs back to the populated form. The problem is that upon successful validation before it goes to my save() method it still calls the prepare method...I DONT want this. Functionally the app works fine and it doesn't cause issues. but its a waste of resources to run through the population routines when they aren't even going to be used for anything.

I know the easy solution would be to put the save() in its own action and not implement Prepareable, but I dont want to go that route....i want to keep everything together. so my question is if there is a way to bypass the prepare method for certain situations? similar to maybe how the *_input will bypass validation schemes.
 
Raymond Holguin
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well it occurred to me to try to override the prepare interceptor to bypass the save() method similar to how the validator interceptor is setup to bypass the input() method....but then i found that will not solve the issue for another reason.

if the validation fails it does not redirect the action back to action_input even though the action_input jsp page is called. the current action is still action_save for failed validation so if i did overwrite the prepare interceptor the form would not get repopulated since the prepare would be skipped.

looks like i need a new approach somehow...
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic