I have a little complicated problem, but I'll try to simplify it to exlain what I am doing.
For some complicated reasons, I need to do Action Chaining (I know this is not recommended generally, but I must do it because some complicated work has been delegated to one generic action).
So, in a simplified version this is what it is --
I have two actions - action "A" and action "B", out of which action A is generic action and need to be used by many forms/pages. Now my form posts 2 parameters, say "X" and "Y" to action A. action A processes only parameter "X" and forwards it to action "B" -- which is supposed to process parameter "Y". However, this parameter "Y" is not available to action "B" after this forward, and I wonder what can I do to get thsi working.
My configuration correctly has this forward configured as "redirect=false"
What can I do here?? We do need to have action "A" pretty generic, so action chaing is must for making it work for various purposes. How can I allow action B to access parameter Y??? Is there any configuration parameter that I can twist and make this work?? I am using Tomcat 5 as my container.
hmmm...if you are not redirecting then the execution of both actions should occur on the same request so it sure seems like all values submitted from the page should still be available on the request. Are you sure that "Y" is being submitted and that it is not available in Action "B"?
I have seen it mentioned on the Struts Developer mailing list that the Struts internals do not handle action chaining very well. I do not know what the specific issues are though.
Really? Even when the forward does not redirect? I would have thought that both actions would have seen the same request object, but action chaining (without redirecting) is something that I avoid...mostly just so the URL in the browser is updated.
BTW, here is a utility method that I put together to add a parameter to an ActionForward. It might be a bit of overkill, but I like defining the forwards in struts-config.
Joined: Feb 15, 2005
I know, Brent, it seems odd, but this is what seems to work. Anything put in the request using the setAttribute method will get passed, but parameters have to be repackaged and passed again.
Like you, I avoid action chaining. Action chaining is usually an indication that one is putting too much business logic in the Action class as opposed to business delegates and model classes.