[Opensource] prePerform(), postPerform() Template Methods
larry hamel
expresso at codeguild.com
Mon Nov 10 18:14:50 PST 2003
any more feedback on this? Mike thought it already existed in struts actions, but I can't find such a feature that is accessible to a controller.
larry
---------
I perceive a need for a Template Method pattern to enable pre- and postprocessing on the main controller path,
nextState.perform(stateForm, myRequest, myResponse);
(Line 1310 in Controller.Java)
For example, common code dealing with a header and footer could be put there.
Since a controller is just an arbitrary collection of states (less arbitrary if you use flow control), it seems OK that all states within a controller would share the same pre- and postprocessing.
Specifically, consider the following to replace line 1310:
prePerform(nextState, myRequest, myResponse);
nextState.perform(stateForm, myRequest, myResponse);
postPerform(nextState, myRequest, myResponse);
Where the implementation is just a no-op in the superclass.
void prePerform(nextState, ControllerRequest request, ControllerResponse response) throws ControllerException {}
What you think?
larry
More information about the Opensource
mailing list