This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Struts and the fly likes setParams from action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "setParams from action" Watch "setParams from action" New topic
Author

setParams from action

Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Hello
I have never had a reason to do this, and I could do it through a formbean, but I want to pass control to another action and set the parameter values. How would I do this from within the originating action? Sorry if this is obvious, but then everything is to someone, grin. tia.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The easiest is to define a forward that points to the second action.

Note that action chaining is *strongly* discouraged. Searching the web for "struts +action chaining" turns up a number of references which may or may not be helpful depending on what you're actually trying to accomplish.
Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Hi Dave
Thanks. Yes, I know that is a gauche hack, however what design would you recommend? I have an action/form bean process from which I want to call another action/form bean process. Is it as simple as include the params of action2 in formbean 1 and just set them in action1?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'd recommend just about anything else.

Ideally, actions are a relatively thin layer between web and business logic. If business logic is wrapped up in reasonable ways it's as easy as using the same business logic in the action in question rather than running the request through another action. I have yet to run across a legitimate reason to chain actions, but that could just be a consequence of the particular apps I've written.

There are a few ways to chain actions in S1; the search query I offered before turns up most (or all?) of them.
 
Don't get me started about those stupid light bulbs.
 
subject: setParams from action