aspose file tools*
The moose likes Struts and the fly likes Thoughts on chaining Actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Thoughts on chaining Actions" Watch "Thoughts on chaining Actions" New topic
Author

Thoughts on chaining Actions

Rich Smyth
Ranch Hand

Joined: May 30, 2002
Posts: 87
A recent thread here touched upon the 'hazards' of chaining Actions. While there has been debate in various forums over good vs. bad chaining I'm not quite sure of what is meant by chaining actions.
Depending on the source, it would appear to me that actionA is considered chained to ActionB if any of the following apply:
a) the operation started by ActionA is incomplete unless followed by ActionB.
b) ActionB can not succeed unless preceeded by ActionA.
c) ActionA simply fowards to /ActionB.do (regardless of the redirect option)
d) ActionA forwards to /ActionB.do without a redirect (with redirect is ok)
e) ActionA builds the ActionForward to ActionB on the fly.
Is there a more rigorous definition? Is the above accurate? Complete?
My first reaction to the NEVER CHAIN ACTIONS statements was that somebody is recommending that all Actions forward only to JSPs?
Upon further reading I think that the intent of that statement is to discourage having Actions figure out or be dependent upon a specific flow. The recommended approach is to reuse very specific Actions in multiple mappings and let the mapping dictate the forwards. The Actions themselves are dumb as to the flow.
But even in this recommended approach, don't we still end up with an action chain?

Rich
I'm posting this to figure out what I know and to hear from others who have wisdom to share on this topic.
Rich
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5019
    
    8

I'm being lazy today (and I'm also at work and stealing in posts, as usual) so it would be great if somebody would care to expound on the Cons of chaining actions.
In my limited experience with Struts, chaining is not all that harmful if done in moderation and in good taste I see Action chaining as similar to Filter chaining. Also, if you see one Action beginning to have too much of a dependency on another upstream (or upchain as it may be) Action, shouldn't this be taken as a sign that some refactoring is in order?


Junilu - [How to Ask Questions] [How to Answer Questions]
Rich Smyth
Ranch Hand

Joined: May 30, 2002
Posts: 87
Also, if you see one Action beginning to have too much of a dependency on another upstream (or upchain as it may be) Action, shouldn't this be taken as a sign that some refactoring is in order?

Yes. Then again it's not hard to agree
Clearly using action chaining (and I used the term without having a clear definiton - see original post) is ok in the context of say, dispath type actions, where the very design suggests that the dispatch action can be chained to another Action. And clearly action chaining is bad in situation where it introduces errors, such as when action1 sets a property that is subsequently lost when the request is forwarded to action2, which shares the same ActionForm.
In between these extremes there are the situations where you determine how the chaining contrains the reuse of your actions and then act accordingly.
If all there was to this issue was "use your common sense" then there would be no issue at all.
So what am I missing?
Rich
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thoughts on chaining Actions