I notice that as soon as someone is talking about forwarding to another Action all these flags go up and "Chain of Responsibility" gets said.

The flags go up just because Struts was not designed to make two passes through the RequestProcessor with a single HttpServletRequest, and action chaining causes it to do that. Clearly, this works anyway in some cases, but sometimes the issues which weren't accounted for in the design come up, and so we warn people.


This is an excellent point where what we are talking about is not that we are interested in doing CoR. There's a razors edge it appears. On one hand its recommended that to apply MVC properly, all requests should go through the Action and be forwarded to a JSP, but if said Action "initializes" important values which the JSP needs to generate the presentation. Then forwarding has to be to the Action, and thus chaining occurs. But is the Goal really CoR? No, the goal is that I want to intialize values in my view from my model.

Obviously, CoR is not the cure-all for everything. Also note that one could implement this "page prep" step in the request processing cycle without using struts-chain. One would simply extend RequestProcessor and modify the implementation of processForwardConfig(...) to add in some handling before actually dispatching to the view path. Of course, then, you'd probably have to look at the TilesRequestProcessor and figure out how its overriding implementation of that method would have to change to co-operate with this new approach. It's certainly possible.


One possible solution that fits within the strategy would be to implement a more restrictive DispatchAction with a method specifically for "initialization" and a method specifically for "execution", create to different Actions, one for intialization and one for execution. forwarding to "IntializationActions" from "ExecutionActions" is allowed, but forwarding to "ExecutionActions" from "InitializationActions" or other "ExecutionActions" is not.

I'm not sure I totally understand, but that shouldn't stop you! How would you configure this? With a specific subclass of ActionMapping? Where would responsibility for enforcing these rules go -- in the more restrictive DispatchAction? Or are you saying that the RequestProcessor should break down processActionPerform() into a two-phase approach? If that's the case, why is it better to do that without using CoR?



Joe
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn back; I'll know I'm in the wrong place."
- Carlos Santana

Reply via email to