This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have 4 forms which together compose an entity-adding action (each part is validated differently and individually, therefore, they are split). Now I have set up everything so that I go from tile to tile via the action and everything seems to work well so far.
However, each of the actions points to the same class and the information (instance variables) are always only passed from the one step to the next but then lost when the following form is loaded.
My struts.xml looks like this:
And basically everything seems to be almost great, only problem is that the steps should be:
And the information in the instance of de.nak.stundenplandb.action.EditVeranstaltungsreihenlisteAction (if I look via Debug) is only passed from 1 to 2, then in 2 some stuff is added and then when I move to form three the settings from form one are lost.
Any ideas how I can ensure that all these actions use the same instance of de.nak.stundenplandb.action.EditVeranstaltungsreihenlisteAction?
Are you using Struts 1 or Struts 2? Looks like Struts 2.
In any case, using instance variables is a Very Bad Idea. In Struts 1, there's only one instance of an action created so instance variables will cause race conditions. In Struts 2, a new instance of an Action is created with each request, so you'll lose the instance variable values.
I would us a user session to store the values you want to carry along the process.