• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts2: bypass the prepare method?

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic