In the situation where you want to keep the field values passed from one action to another you could configure the scope of the field. Just place the same field with getters and setters in each action, in your case it will be action1
and action2
. The field name is txtid
. As well as scope
interceptor doesn't include in the defaultStack
you should reference it in the action configuration.
For example:
<action name="action1" class="com.package.action.AddId">
<result>/jsp/page2.jsp</result>
<interceptor-ref name="basicStack"/>
<interceptor-ref name="scope">
<param name="key">mykey</param>
<param name="session">txtid</param>
<param name="autoCreateSession">true</param>
</interceptor-ref>
</action>
<action name="action2" class="com.package.action.AddForm">
<result>/jsp/page3.jsp</result>
<interceptor-ref name="scope">
<param name="key">mykey</param>
<param name="session">txtid</param>
<param name="autoCreateSession">true</param>
</interceptor-ref>
<interceptor-ref name="basicStack"/>
</action>
Now you have the scope with the key mykey
and field txtid
under it. Providing accessors to the field in each action will make transfer field value from one action to another.
In the example above used the basicStack
which is a skeleton for the interceptor stack and it does not include some interceptors including a validation
interceptor.
If you need to have other features to your actions, you should either construct a custom stack or reference other interceptors in the action configuration.