Erik Hatcher wrote:
> Obviously my only use-case/need right now is to have an additional String
> key parameter passed to a perform-like method.  So I'm ok with locking it
> into that method signature if that'll get it committed, but I still think a
> DispatchAction subclass should be more extensible than that.  Maybe you're
> proposing something more extensible and I'm just not seeing it yet though.

The String key would be passed up in LookupKeyAction version, and
developers using this one would subclass the "extended" perform method. 

With DispatchKeyAction, the key is used to call the method itself and
does not need to be passed. Since reflection is being used, the key is
implicit in the name of the method invoked.

In order to pass a parameter, it has to come from somewhere. Everything
that perform "knows" is in the original signature, where any reflected
method can get it. 

Actions often need to pull properites and parameters out of the request
and mappings. But this is best handled by other utility methods in the
class, that each reflective method could call. 

So if the use-case is I want to pass "glockenspeil" from the request,
then the class should have a protected "String getGlockenspiel(request)"
method that any of the reflective methods could call (and an additional
subclass could override).

I've annexed a DispatchAction with the initial refactoring I mentioned.
The idea is that you could start by extending this, overriding perform
with your own method-name discovery routine, and then call 

return dispatchMethod(mapping,form,request,response,name);

at the end (without calling super.perform(...) at any point).

Of course, additional refactoring to encapsulate error handling could be
done, since we call the same "sendError" block several times, but it
would just be more instances of "extract method".

And some point between Struts 1.x and Struts 2.x, I'd like apply a great
many instances of "extract method" throughout the framework, since many
of our methods are a trifle long. 


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

Attachment: DispatchAction.java
Description: application/unknown-content-type-visualcafefile.document

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to