User Interface -> Action1 (input is Form1)-> Action 2 (input is Form2) ->User Interface
Action1 and Action2 are Action classes.
Action1 and Action1 are configured in struts-config.xmxl.
Action1 takes Form1 as input.
Action2 takes Form2 as input.
Form1 and Form2 are ActionForm.
Following are the questions:
1. If Form1 and Form2 are of the same class, will Form2 get magically populated by the values obtained from Form1, when Action1 forwards to Action2? 2. Will Form2 values be empty? 3. If Form1 and Form2 are of different class, then what value will Form2 have? 4. If Form1 and Form2 are of the same class, then what value will Form2 have? 5. Is it a good idea to do Action chaining? Servlet chaining was never recommended.
It sounds like you are talking about Struts 1.x and not about using redirect="true" for the forward to Action2. I am not an expert in this area mostly because I do not use this type of pattern because several references say that Action Chaining with Struts 1.x is not recommended.
My understanding is that when the processing for Action2 is called, it has no knowledge of Action1. The Action2 processing will go through the normal steps of creating a form instance (if needed) and populating the form with values from the request, validating your form (if needed) and calling your execute method. So for question #1) Form2 gets populated from the request, not from Form1. If you change values on Form1 during Action1 then Action2/Form2 will not see the changed values. My understanding gets real fuzzy if you talks about session scoped forms.
It helps to give real names to your examples if you are looking for help. For example if you had the two actions SaveUserProfileAction and SaveUserCreditAction that you were trying to chain together I would suggest using one action and calling separate business layer methods. If you had the two actions SaveUserProfileAction and DisplayUserSearchResultsAction (which is a very common scenario for me) then I would suggest that you redirect to the second action.
subject: Value of ActionForm in second Action that is chained