Reputation: 31
I have a requirement to call action A multiple times from action B in the same method call. Is there any way to achieve it? I can give some background. I have a product specific API that is internally implemented with struts and the action can accept only one id and one file object. However, I have a requirement to store the same file for multiple ids. So can I use a custom action class that can receive multiple ids and in a loop call the action class that comes with the product. Also, can I pass the form data to the next action class through an interceptor
Upvotes: 0
Views: 915
Reputation: 2770
I have not tested it and probably dont have time to try it. But I think you can try this way to call a single action multiple times. In struts.xml use redirect on success to same action name.Example
<action name="onSubmit" class="com.example.SubmitAction" method="upload">
<result name="success" type="redirect">onSubmit</result>
<result name="error">Success.jsp</result>
</action>
OR
<action name="onSubmit" class="com.example.SubmitAction" method="upload">
<result name="success" type="redirect">onSubmitRedirect</result>
<result name="error">Success.jsp</result>
</action>
<action name="onSubmitRedirect">
<result name="success" type="redirect">onSubmit</result>
</action>
You can use error condition to terminate you loop. Try it I will be glad to know its results.
Upvotes: 0
Reputation: 21
You can Call same Action Class multiple times on form submit through different action names, something like deleteUser, editUser, addUser on Same UserAction class.
Hope, it will fulfil your purpose.
Upvotes: 1