commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Germuska <>
Subject Re: [chain] LookupCommand's return value
Date Thu, 17 Feb 2005 16:11:38 GMT
At 11:52 PM -0500 2/16/05, James Mitchell wrote:
>I'm just now catching up on some of this....but I was 
>wondering.....if you configure "ignoreReturnValue" or 
>"abortIfContextValueTrueOrNull" or "whatchaMaCallit", then how would 
>you (in a looked up chain) tell the calling chain to abort without 
>having to throw an exception?

When a command returns false, that is intended as a sign to its 
caller that it thinks it has "finished".  ChainBase interprets a 
"true" return from a command as a sign to stop executing the chain. 
It also returns whatever it received from the last command it 
executed, so the fundamental design denies the possibility of 
autonomous subchains and commands.  I can see where this would 
sometimes be the way you'd want it, but I think that if it's the only 
way, one must configure chains relatively obtusely in order to ensure 
that conditional commands never get called, or, as in Struts, one 
must burden commands with more contextual knowledge than they should 
have -- there's absolutely no reason an "ExecuteAction" command 
should care if the form was valid or not; something else should 
prevent it from being called in that case.  I thought an "abort 
chain" command was a good idea, but it doesn't work in the current 
design.  The alternative is to relegate the 
"only-if-validation-passed" commands to their own sub-chain which 
only gets executed if validation passed.

So for now, I think the best strategy is a variant of LookupCommand 
which branches: perhaps  generically implemented with a context key 
name to look up a boolean value and then configured with a "true" 
command, a "false" command, and perhaps a "null" command.

That one would be a lot tidier with the not-yet-released Chain 
functionality to specify a catalog/command pair with a single String. 
Is it time to roll a 1.0.1 (or 1.1.) commons-chain release?  Is there 
anything else which should maybe go in it?


Joe Germuska       
"Narrow minds are weapons made for mass destruction"  -The Ex

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message