commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Germuska <>
Subject [chain] LookupCommand's return value
Date Wed, 16 Feb 2005 03:55:10 GMT
I just realized that LookupCommand returns the return value of 
whatever command it looks up and executes.  This was 
counter-intuitive to what I was trying to achieve, and, I would 
argue, limited if not broken.

     public boolean execute(Context context) throws Exception {

         Command command = getCommand(context);
         if (command != null) {
             return (command.execute(context));
         } else {
             return (false);

As it is now, there's no way to abort a looked-up chain without 
causing the base chain to also abort.  It seems like this would not 
always be the desired result.  Specifically, in Struts, I would like 
to implement a command which aborts the chain if the form is invalid 
so that we can eliminate three or four repetitive tests for the same 
condition in commands which follow validation.  It seems like those 
commands shouldn't need to know the condition; that leads to too much 
coupling between the commands.

I'm sure one could reorganize the overall config so that the first 
chain ended without being aborted, and then the commands which would 
have come after are instead on a separate chain behind a conditional 
Lookup command.  This isn't that hard to do, but I'm still not sure 
that I believe the class as implemented should *always* return the 
value of the looked up command.  Could we make a config value out of 

Speaking of a conditional Lookup command, I still think it might be 
neat to implement that using instead of having to write Java code to 
evaluate simple conditions.  It could be like this:

<command className="...ConditionalLookup"
	condition="${context.formValid or empty context.formValid}" />

<command className="...ConditionalLookup"
	condition="${not context.formValid}" />

This could also be used for lookups:
<command className="...ExpressionLookupCommand"
	command="${context.commandName}" />

Note that these are run-time expressions, not simply config variables.

I'm just hesitant to add a new dependency on my own whim.  JEXL isn't 
very heavy (132 K) but I think people are keen on keeping Chain light 


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

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

View raw message