You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joe Germuska <Jo...@Germuska.com> on 2006/05/01 00:47:03 UTC

Re: Is Action Chaining Strongly Discouraged?

On 4/30/06, Caroline Jen <ji...@yahoo.com> wrote:
>I have seen some discussions on this forum regarding
>action chaining.  Primarily, the advices are to think
>through the business logic before making decision on
>chaining actions.
>
>What are the disadvantages of action chaining?  Why
>action chaining is not a good practice?

http://wiki.apache.org/struts/ActionChaining

As noted in that page, ActionChaining is using Struts in a way which 
often works, but for which it was not specifically designed.  It's 
possible that you might run into some odd situations where the 
assumption that a single HttpRequest results in only a single pass 
through the RequestProcessor causes something to go wrong.

I usually just refactor my app when I find myself wanting to use 
action chaining, but many people just do it and find that it works.

Joe

-- 
Joe Germuska
Joe@Germuska.com * http://blog.germuska.com    

"You really can't burn anything out by trying something new, and
even if you can burn it out, it can be fixed.  Try something new."
	-- Robert Moog

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is Action Chaining Strongly Discouraged?

Posted by Dakota Jack <da...@gmail.com>.
You do it by redefining the form relation to the action so that a form
acts as a passage between actions Action1 --> Form12 --> Action2. 
Using action chaining is horrible.  Look at the code and you will see
why.

On 4/30/06, David Evans <ds...@berndtgroup.net> wrote:
> below...
>
> On Sun, 2006-04-30 at 17:47 -0500, Joe Germuska wrote:
> > On 4/30/06, Caroline Jen <ji...@yahoo.com> wrote:
> > >I have seen some discussions on this forum regarding
> > >action chaining.  Primarily, the advices are to think
> > >through the business logic before making decision on
> > >chaining actions.
> > >
> > >What are the disadvantages of action chaining?  Why
> > >action chaining is not a good practice?
> >
> > http://wiki.apache.org/struts/ActionChaining
> >
> > As noted in that page, ActionChaining is using Struts in a way which
> > often works, but for which it was not specifically designed.  It's
> > possible that you might run into some odd situations where the
> > assumption that a single HttpRequest results in only a single pass
> > through the RequestProcessor causes something to go wrong.
> >
> > I usually just refactor my app when I find myself wanting to use
> > action chaining, but many people just do it and find that it works.
> >
> > Joe
>
> How do you handle the population of the contexts which are passed to the
> jsp to which you are forwarding? The one use of chaining that seems to
> make sense to me is the forwarding to a setup action that prepares the
> contexts with whatever objects the jsp may need to display. I have heard
> people say that this setup functionality should be moved to its own
> method in the business layer that could then be called by the forwarding
> action, but how does this actually look? The objects have to be put in a
> web tier context object, how do you keep that layer away from the
> business tier?
>
> Is there a reason you don't use the two action (setup and submit)
> approach?
>
> I'm in the process of learning webwork and while i'm at it i'm trying to
> decide on best practices for action architecture. Webwork makes the two
> action thing even easier, because you can specify a method to call on an
> action class in the action mapping, so the setup and submit handling
> methods can exist in the same action class. or you can even specify the
> method to call on an action class in the url using the ! character, as
> in /customer!setup.action.
>
> any advice or insight would be appreciated.
>
> dave
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is Action Chaining Strongly Discouraged?

Posted by David Evans <ds...@berndtgroup.net>.
On Sun, 2006-04-30 at 20:33 -0500, Joe Germuska wrote:
> At 5:10 PM -0700 4/30/06, David Evans wrote:
> >below...
> >
> >On Sun, 2006-04-30 at 17:47 -0500, Joe Germuska wrote:
> >>  On 4/30/06, Caroline Jen <ji...@yahoo.com> wrote:
> >>  >I have seen some discussions on this forum regarding
> >>  >action chaining.  Primarily, the advices are to think
> >>  >through the business logic before making decision on
> >>  >chaining actions.
> >>  >
> >>  >What are the disadvantages of action chaining?  Why
> >>  >action chaining is not a good practice?
> >>
> >>  http://wiki.apache.org/struts/ActionChaining
> >>
> >>  As noted in that page, ActionChaining is using Struts in a way which
> >>  often works, but for which it was not specifically designed.  It's
> >>  possible that you might run into some odd situations where the
> >>  assumption that a single HttpRequest results in only a single pass
> >>  through the RequestProcessor causes something to go wrong.
> >>
> >>  I usually just refactor my app when I find myself wanting to use
> >>  action chaining, but many people just do it and find that it works.
> >>
> >>  Joe
> >
> >How do you handle the population of the contexts which are passed to the
> >jsp to which you are forwarding?
> >...
> >Is there a reason you don't use the two action (setup and submit)
> >approach?
> 
> The reason I don't is because I know that the original design of the 
> RequestProcessor didn't expect there to be two passes through in a 
> single request, so that it's possible (in theory) for some values to 
> be in unexpected state.   Having known that, i've just developed 
> design strategies which don't require chaining.
> 
> We use Tiles in every webapp we do, so I have often used Tiles 
> Controller classes for view population; I've also designed a few 
> strategies implemented with changes to the RequestProcessor (or with 
> custom chain commands since struts-chain) -- but none of which I felt 
> were clearly something which should be committed to Struts proper.
> 
> I know for a fact that many people have used action chaining (and I 
> have at times too) and it hasn't been a problem.  I can't cite 
> specific problems people have raised in the past that traced back to 
> action chaining, but maybe there's something in the archives.
> 
> So it's not so much that ActionChaining is considered "harmful" as 
> it's understood to be potentially surprising.
> 
> Hope that helps
> 	Joe

Thanks it does help. I'm in the "gather as many ideas as possible
stage", so thanks.

dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is Action Chaining Strongly Discouraged?

Posted by Joe Germuska <Jo...@Germuska.com>.
At 5:10 PM -0700 4/30/06, David Evans wrote:
>below...
>
>On Sun, 2006-04-30 at 17:47 -0500, Joe Germuska wrote:
>>  On 4/30/06, Caroline Jen <ji...@yahoo.com> wrote:
>>  >I have seen some discussions on this forum regarding
>>  >action chaining.  Primarily, the advices are to think
>>  >through the business logic before making decision on
>>  >chaining actions.
>>  >
>>  >What are the disadvantages of action chaining?  Why
>>  >action chaining is not a good practice?
>>
>>  http://wiki.apache.org/struts/ActionChaining
>>
>>  As noted in that page, ActionChaining is using Struts in a way which
>>  often works, but for which it was not specifically designed.  It's
>>  possible that you might run into some odd situations where the
>>  assumption that a single HttpRequest results in only a single pass
>>  through the RequestProcessor causes something to go wrong.
>>
>>  I usually just refactor my app when I find myself wanting to use
>>  action chaining, but many people just do it and find that it works.
>>
>>  Joe
>
>How do you handle the population of the contexts which are passed to the
>jsp to which you are forwarding?
>...
>Is there a reason you don't use the two action (setup and submit)
>approach?

The reason I don't is because I know that the original design of the 
RequestProcessor didn't expect there to be two passes through in a 
single request, so that it's possible (in theory) for some values to 
be in unexpected state.   Having known that, i've just developed 
design strategies which don't require chaining.

We use Tiles in every webapp we do, so I have often used Tiles 
Controller classes for view population; I've also designed a few 
strategies implemented with changes to the RequestProcessor (or with 
custom chain commands since struts-chain) -- but none of which I felt 
were clearly something which should be committed to Struts proper.

I know for a fact that many people have used action chaining (and I 
have at times too) and it hasn't been a problem.  I can't cite 
specific problems people have raised in the past that traced back to 
action chaining, but maybe there's something in the archives.

So it's not so much that ActionChaining is considered "harmful" as 
it's understood to be potentially surprising.

Hope that helps
	Joe


>I'm in the process of learning webwork and while i'm at it i'm trying to
>decide on best practices for action architecture. Webwork makes the two
>action thing even easier, because you can specify a method to call on an
>action class in the action mapping, so the setup and submit handling
>methods can exist in the same action class. or you can even specify the
>method to call on an action class in the url using the ! character, as
>in /customer!setup.action.

You can achieve most of this with dispatch actions.
-- 
Joe Germuska
Joe@Germuska.com * http://blog.germuska.com    

"You really can't burn anything out by trying something new, and
even if you can burn it out, it can be fixed.  Try something new."
	-- Robert Moog

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is Action Chaining Strongly Discouraged?

Posted by David Evans <ds...@berndtgroup.net>.
Thanks for the idea. Are you differenciating using request.getMethod()
in the actions execute method?

dave


On Mon, 2006-05-01 at 10:03 -0400, Dave Newton wrote:
> David Evans wrote:
> > Is there a reason you don't use the two action (setup and submit) approach?
> >   
> 
> I just think it's cluttery. I always use POST so it's easy to just split
> my actions into GET and POST handlers; I do the setup in the GET handler.
> 
> Dave
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is Action Chaining Strongly Discouraged?

Posted by Dave Newton <ne...@pingsite.com>.
David Evans wrote:
> Is there a reason you don't use the two action (setup and submit) approach?
>   

I just think it's cluttery. I always use POST so it's easy to just split
my actions into GET and POST handlers; I do the setup in the GET handler.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Is Action Chaining Strongly Discouraged?

Posted by David Evans <ds...@berndtgroup.net>.
below...

On Sun, 2006-04-30 at 17:47 -0500, Joe Germuska wrote:
> On 4/30/06, Caroline Jen <ji...@yahoo.com> wrote:
> >I have seen some discussions on this forum regarding
> >action chaining.  Primarily, the advices are to think
> >through the business logic before making decision on
> >chaining actions.
> >
> >What are the disadvantages of action chaining?  Why
> >action chaining is not a good practice?
> 
> http://wiki.apache.org/struts/ActionChaining
> 
> As noted in that page, ActionChaining is using Struts in a way which 
> often works, but for which it was not specifically designed.  It's 
> possible that you might run into some odd situations where the 
> assumption that a single HttpRequest results in only a single pass 
> through the RequestProcessor causes something to go wrong.
> 
> I usually just refactor my app when I find myself wanting to use 
> action chaining, but many people just do it and find that it works.
> 
> Joe

How do you handle the population of the contexts which are passed to the
jsp to which you are forwarding? The one use of chaining that seems to
make sense to me is the forwarding to a setup action that prepares the
contexts with whatever objects the jsp may need to display. I have heard
people say that this setup functionality should be moved to its own
method in the business layer that could then be called by the forwarding
action, but how does this actually look? The objects have to be put in a
web tier context object, how do you keep that layer away from the
business tier? 

Is there a reason you don't use the two action (setup and submit)
approach?

I'm in the process of learning webwork and while i'm at it i'm trying to
decide on best practices for action architecture. Webwork makes the two
action thing even easier, because you can specify a method to call on an
action class in the action mapping, so the setup and submit handling
methods can exist in the same action class. or you can even specify the
method to call on an action class in the url using the ! character, as
in /customer!setup.action. 

any advice or insight would be appreciated. 

dave




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org