Tony Dahbura wrote:
I have an action that needs to call another action and pass data to it. The first action has the data in a form action1form, but the second action uses a different form bean action2form. The first action has completed its work and needs to pass off to this second action as well as pass on some data.
All the form beans are kept in request scope (cannot use session scope).
How do I call the second action and either build its action2form prior to
the call or pass a set of values from the current action onto it so it can
access them.

I thought about stuffing the values in the request header but was wondering
if there was a better/approved way to build the form bean and pass it as part of the return mapping.findForward(Globals.FORWARD_SUCCESS) call from the first action?

The first thing to ask is, why are you trying to do that? Having one action invoke another is usually called 'Action Chaining' and is considered usually considered a bad idea in Struts. The one main exception is if you have action A which handles a form submission or other processing task which then forwards to action B, where action B is a setup action that ends up forwarding to a view (JSP, etc.).

To tell Struts to forward control from one action to another, you can just set up the call to the next action as the value of your <forward> in the first actions mapping in struts-config.

The second action will see the same set of request parameters as the first action (because you're doing a forward, so it *is* the same request). If you don't want that, you can add redirect="true" to your <forward> config.

If you then also want to specify one or more request parameters when invoking that forward, you need to specify them in your first action. That's a bit messy in older versions of Struts; you have to create a modified clone of the action mapping and return that. In Struts 1.2.8(?) and later, you can achieve the same thing more cleanly with RedirectAction [1].

Struts will take care of building action two's form bean for you. You shouldn't need to build one yourself and, in any case, there is no way to pass one as part of the execute method's return.

L.

[1] http://struts.apache.org//struts-doc-1.2.8/api/org/apache/struts/action/ActionRedirect.html


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

Reply via email to