• 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

action chaining

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
I have a situation where I have to merge work between different developers of a struts enabled web-app.
Every jsp has 2 actions. Like:
OUTPUT ACTION1 ----> JSP1 -----> INPUT ACTION1

OUTPUT ACTION2 ----> JSP2 -----> INPUT ACTION2

The output action is used to populate the jsp fields. and the Input Action to persist the data.

Now to merge 1 and 2. I know I can

forward INPUT ACTION1 to OUTPUT ACTION2 and I understand this is action chaining.
However I read online that action chaining is not recommended.

My Questions:
1) If the above is an acceptable solution
2) Why is it not recommended to do action chaining

Thanks
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's true that Action chaining is not recommended but your scenario is an exception. The "output" Actions you refer to are often called Setup or Populate actions.

As far as I'm concerned, this is a best practice when using Struts

Craig McClanahan's talk on JSF refers to this Struts practice as bad but blames the framework rather than the practice.
[ August 02, 2005: Message edited by: Marc Peabody ]
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[ August 02, 2005: Message edited by: Marc Peabody ]
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chaining actions is certainly possible, and the solution you propose would work.

The objections to chaining actions have more to do with programming style than anything else. The reason most authors object to it is that it indicates your code may not be structured in the best way to follow the MVC model.

In the Struts framework, the Action class is 100% controller. This means that it's job is to coordinate between the view and the model. As such, it shouldn't have model logic or view logic contained in it. If a page requests information that must be obtained from a database, the action form should call on a model object to perform that database access rather than doing it within the action class.

Where I'm going with this is that if you have to do action chaining to make your application work, you probably have too much model logic in your action class.

To use your example, most of the what Output Action 2 does to get it's data should be contained in a model object. Therefore, it should be fairly easy for Input Action 1 to call the same method on the model object that Output Action 2 does. You could thereby eliminate Output Action 2 altogether.
 
Pranav Sharma
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys.

Merrill, the web app actually is structured pretty well, with model objects implementing majority of the population behavior. However my problem is with logistics, cause we have two teams in California and Maryland.
I did not want to mess with the actions written by the other team and so the chaining.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic