You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Benedict <pa...@yahoo.com> on 2005/11/08 00:50:30 UTC

Why Chain over Action?

Subject line says it all.

I've been contemplating this topic. The best answer I can give here is that in Struts 1.3, you
really don't have to ever deal with an Action class at all - use ChainAction as an entry point
into your chains. But how would you model a real world application using the chains? Let me guess:
see the example applications :-) If there are more brilliant answers, I'd like to hear them.

Thanks!!
Paul


		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

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


Re: Why Chain over Action?

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
I'm currently in the middle of a project at work that makes heavy usage 
of CoR (it's only a very small webapp component, the vast majority of it 
is business process, and that's a rather large piece).  I am using the 
CoR implementation in Java Web Parts rather than Commons Chain because 
it has some added capabilities I need, but that's only a minor point.

This project is conceptually very simple: parse a couple of input files, 
for each record in them create an object, then run that object through a 
long series of rules and annotate in various ways along the way, or 
possibly reject it at certain points.  As usual, the devil is in the 
details though... many of those rules are incredibly complex in and of 
themselves.  Also, one of the key requirements is to be able to quickly 
and easily change the rules, and to customize the processing for 
different clients.  CoR makes this all very easy.  And, because the 
Commands are so simple, they can be very easily unit-tested, which is a 
big plus.  It wouldn't have been too tough to do this without CoR, but 
it makes it considerably more elegant IMO.

Coming back to chains in Struts, I think it will be interesting to see 
how people wind up using it... I can see numerous opportunities to 
modify the request processing chain for various reasons (my own StrutsWS 
project has already been ported to 1.3 as just one example)... What will 
be more interesting is how people use the capability OUTSIDE the RP 
cycle... well, an Action is still technically part of the RP cyclce, but 
I think you know what I mean :)  What will people come up with in terms 
of using Commands instead of Actions?  I'm interested to see where that 
leads.

Frank

Paul Benedict wrote:
> Subject line says it all.
> 
> I've been contemplating this topic. The best answer I can give here is that in Struts 1.3, you
> really don't have to ever deal with an Action class at all - use ChainAction as an entry point
> into your chains. But how would you model a real world application using the chains? Let me guess:
> see the example applications :-) If there are more brilliant answers, I'd like to hear them.
> 
> Thanks!!
> Paul
> 
> 
> 		
> __________________________________ 
> Yahoo! FareChase: Search multiple travel sites in one click.
> http://farechase.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> .
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

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


Re: Why Chain over Action?

Posted by Ted Husted <te...@gmail.com>.
On 11/7/05, netsql <ne...@roomity.com> wrote:
> 1st, you can use Commons Chain in Struts 1.2.X. In 1.3 the request
> processor is done in Chain... but a user can't tell.
> You can use Commons Chain (a CoR pattern) outside of Struts.

For more about Commons Chain generally, see also

* http://struts.apache.org/struts-core/userGuide/preface.html#chain

I ported Chain to C# and use it as a business facade for my ASP.NET
applications.

In many ways, it's like using WebWork interceptors. Here's a quote
from WebWork in Action about Interceptors that also sums up my own
experience with using Commons Chain.

"{You are able to] modularize repeated code without having to build up
brittle class hierarchies of abstract parent [classes], delegating
part of the processing to the subclass after surrounding it with some
pre- and post-processing. The class hierarchy approach works fine for
small applications; but as the size and complexity of your application
grows, it becomes difficult to pull together the right class heirarchy
to provide to more optional services to your actions."

I use Commands like finely-grained services and use Chains to combine
the services into a transaction script for the action. Commands are
great for assembling UI pages. You can have a Command for each
drop-down list or other rich control, and chain them together to meet
the page's requirements. If controls come or go, it's easy to move
them in and out of a Chain configuration.

Likewise, if my business logic needs to do the equivalent of a "move",
I can chain a "copy" and "delete" Command together. If the copy fails,
the Chain terminates, and you can pass back a message in the Context.

HTH, Ted.
http://husted.com/poe/

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


Re: Why Chain over Action?

Posted by netsql <ne...@roomity.com>.
1st, you can use Commons Chain in Struts 1.2.X. In 1.3 the request 
processor is done in Chain... but a user can't tell.
You can use Commons Chain (a CoR pattern) outside of Struts.

It lets you xml configure a command to execute, or ... several commands 
(hence it's called Chain) Anyone can look at XML and see where to start 
reading code (just like "old" struts).
I use Chain... w/ JDNC!

I used to use IoC (hivemind) where you 1st define a sginature, etc. In 
CoR... signature is allways same, and you don't have to change it to 
pass in more arguments or to return more arguments or arguments change 
(it's just a map/context) thus giving you less think time and more code 
stability. I allso played w/ JMX to configure "commands" but... for some 
reason I stoped, and only use Chain.

In 1.3 you don't have to use a chain action.
If you do use chain action... you application no longer depends on Struts!
Eventually you have many commands... and my developers cofigure a 
"chain" of resuable comaands, they fit togeter w/o planing.
So a comand x from chain y can be used with command a from chain b to 
from chain alpha (x + a). This was discovered by accident.
In esence, it's modular programming.. but more so.

(Now I stoped doing even that and am moving everything to Groovy to beat 
up on Ruby, Python crowd w/ Java productivity... you just write so fast 
and it just works, almost readable pseudo code)

hth,



Paul Benedict wrote:
> Subject line says it all.
> 
> I've been contemplating this topic. The best answer I can give here is that in Struts 1.3, you
> really don't have to ever deal with an Action class at all - use ChainAction as an entry point
> into your chains. But how would you model a real world application using the chains? Let me guess:
> see the example applications :-) If there are more brilliant answers, I'd like to hear them.
> 
> Thanks!!
> Paul
> 
> 
> 		
> __________________________________ 
> Yahoo! FareChase: Search multiple travel sites in one click.
> http://farechase.yahoo.com


-- 
thx,
.V

Your Roomity Broadband Community <http://roomity.com/demo.jsp>

cell: 917 825 3035 in DFW
email: netsql at roomity.com


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