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 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 this 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 chaining 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.
I can suggest to you one way, If it works for you. In this case, do not read forward mapping from the struts config only, if you want pass some parameter from action A to Action B you can use following segment of code in Action A while forwarding the request.
String URL= "supplierDetail.do?parameter=SUP&key=123";
ActionForward actionForward= new ActionForward(URL);
I can't use this as being a genric action, action A wouldn't know what URL it needs to forward to in each case. The next action could be action B or action C or whatever, that's the reason why we made action A as geneic action.
Hmmmmm.....Maybe I can take fwdURL as parameter to action A and create forward fom there. Let me try that..it should work.
Instead of using the Action Chaining, you can use the RequestProcessor of Struts to do all kinds processing before the request is forwarded to the actual Action class.
In our appl I've extended the RequestProcessor of struts and overridden the boolean RequestProcessor.processPreprocess(). I check the user authorizations in this method. If the user is authorized then return true. Request is then processed by method processActionPerform().
You can also use this approach to process parameters from the URL and then return true.
Does this solve ur problem ?
I am already using my own request processor for differnt purpose. This action is a generic action that we anticipate would be used for 7-8 common tasks. We are also handling user authentication is request processor itself.
I hope it could be an issue with the request processor.
Does it manipulate ur request in a way u loose the parameter Y, ideally u shud be able to get the parameter Y in the chained action, but i may be wrong but i have a feeling that something is not right in the request processor.
if u are manipulating ur request, try using HttpRequestWrapper.