This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

several actions with same action class and only one instance  RSS feed

Jonas Eichhorst
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

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?

Thank you very much in advance!
Joe Ess
Posts: 9428
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!