At 9:23 AM +0100 5/25/05, Marco Mistroni wrote:
Hello Joe & all,
I have one question regarding the chain..
Am I correct to assume that The SelectInput command that comes after
ValidateActionForm in chain-config.xml should be called in case
validation fails?
How does that happen? Javadoc says that
/**
* <p>Validate the properties of the form bean for this request. If
there are
* any validation errors, execute the child commands in our chain;
otherwise,
* proceed normally.</p>
*
* @version $Rev: 153658 $ $Date: 2005-02-13 14:26:03 -0500 (Sun, 13 Feb
2005) $
*/
I think that JavaDoc is misleading. I had wanted to do some
rearrangement to the chain around this issue, but have not yet. (To
be honest, I'm not really sure what "child commands in our chain"
means!)
Here's how it works now: in the process action chain, the
ValidateActionForm command does the validation and sets a flag in the
context. Then, each subsequent command in the chain inspects the
value of this and controls its behavior accordingly.
This is kind of clumsy, and entangles the commands too much. It
would be better to "abort" the chain when the form is invalid, at
least as soon as possible. The problem is that commons-chain 1.0
treats a "true" return from a lookup chain as a signal to end ALL
chain processing, not just that chain which was looked up. This has
been addressed with a configurable property on LookupCommand in an as
yet unreleased version of commons-chain. With that, one can "abort"
a sub-chain without interrupting the processing of the source chain.
There's still the awkward bit of having SelectInput separate from
ValidateActionForm -- you have at least one class which needs to be
invoked paying attention to this value in the context. I've thought
of a few possible chain design approaches, like a branching command
or a conditional lookup command, but none have felt so compelling
that I wanted to push them in yet.
but as far as I could see, SelectInput is just another command that
comes after ValidateActionForm... and, one thing that make me more
confused, is that if ValidateActionForm fails, it should return true, so
the next command (which is SelectInput) shouldn't get executed.......
That's not true -- as noted above, in commons-chain 1.0, no command
in a chain may ever return true without cancelling all chain
processing. I found this counter-intuitive, as it seems do you --
and that's why I added the configuration property to LookupCommand.
I'd suggest checking out the code -- it should be pretty easy to
actually trace through it and get a better handle on what happens in
there.
Joe
--
Joe Germuska
[EMAIL PROTECTED]
http://blog.germuska.com
"Narrow minds are weapons made for mass destruction" -The Ex
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]