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...

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?

Pierre Métras

Reply via email to