Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setParams from action

 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic