Reputation: 830
I am creating a wizard in Struts. It cotains 4 steps. For Each step I have separate ActionClass say:-
and in each class there are 2 methods input() and process().
I am carrying all data upto the last step in a session. And saving all of them in database in the last step
Similaly 4 action tags in struts.xml like :-
<action name="step1" class="com.mycomp.myapp.action.Step1Action1" method="input">
<result name="success" type="redirectAction">step2</result>
<result name="input">/view/step1.jsp</result>
</action>
<action name="step2" class="com.mycomp.myapp.action.Step1Action2" method="input">
<result name="success" type="redirectAction">step3</result>
<result name="input">/view/step2.jsp</result>
</action>
But I think I am going wrong. Please Tell me How will I handle This case?
Upvotes: 1
Views: 1357
Reputation: 75996
There is something conceptually wrong here - and the conceptual error lies before the wizard scenario.
For one thing, a Struts2 action should not (typically) have a "input" method. A Struts2 action should DO SOMETHING (method) on behalf of a client request (URL), and return a RESULT (string) which returns a new VIEW (jsp page) to the client.
"input" is (conventionally) just a RESULT that corresponds to the case "I cannot do what I (action) am supposed to do because the data entered is incomplete, or invalid; let's tell the user to try to input the data again"
You should be sure to understand the simplest use cases (the typical input form with a result message), before attempting a wizard. See here.
Upvotes: 2
Reputation: 23587
If you are trying to develop some wizard like functionality than there is already an interceptor in struts2 for the same Scope Interceptor here are the details for the same http://struts.apache.org/2.0.14/docs/scope-interceptor.html
Upvotes: 2