Pierre M�tras wrote:

> Hi,
>
> How can we chain controllers and pass parameters in the MVC model?
>
> Let's start with my understanding of the Struts model.
> In a theorical world, we should have a sequence of events
> from the user on the view that generate actions on the controller side,
> which display a new view, and loop...
>
> A controller is called with a "*.do" URL, that forwards to a "forward". But
> a forward can be a JSP page (a view), or another controller (a URL like
> "/subfunction.do?action=Init", look into the example struts-confi.xml)
> that in turn look for a view...
>
> A mapping is the association of a controller and multiple forwards. An
> ActionForm is used to manage data between the various forward: passing data
> from the controller to the view. Each view expects one associated
> ActionForm (declared in the <form:form> tag).
>
> But passing data from controller to controller is not that easy, because the
> calling controller don't know a priori the ActionForm type expected by the
> callee. A
> solution is to pass request parameters, but forwards don't have
> parameters...
>

You can actually include parameters in the request URI of the forward, but these
wouldn't really be dynamc.  On the other hand, request attributes are still
maintained even if you forward to a "subfunction."

>
> Do we need a setParameter(String name, String value) method in ActionForward
> in order to write:
>
> perform(...)
> {
>     ...
>     ActionForward forward = mapping.findForward("result");
>     forward.setParameter("action", "initChain");
>     return forward;
> }
>
> How other do that?
>

One of the ideas I've been thinking about (for a Struts 1.1 timeframe) is to
support a more "workflow" oriented mechanism for defining actions.  The thought
would be that an application developer would decompose the business functions of
the application into discrete "tasks", and then glue them together with
"scripts" defined in the struts config file.  Struts could then include a
standard Action that executes the script -- the net effect would be to reduce
(or possibly eliminate) the need to write Action classes yourself.  In such an
environment, chaining functions together would become as simple as writing the
appropriate tasks into a config file.

Does this sound like an interesting direction to pursue?

>
> Pierre M�tras

Craig


Reply via email to