• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Maintaining form data across pages

 
Sudhakar k Kanagarajan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to setup a series of jsp pages (jsp1, jsp2, jsp3). Each of these adds or modifies properties (or collections) of object customerForm(supply name/address, add contacts, etc.) This is an "experimental" app I'm putting together to try out struts.
In struts-config.xml, I have the choice of setting the scope parameter for each action mapping. If I set scope to "request", then customerForm is instantiated each time the form is presented - data is lost across forms.

If I set to "session" then I can maintain the data across the various forms, but customerForm.reset() is still called.

My questions:
What is the best way to maintain the customer data across several jsp pages?
Should I just move form data to a customer bean from customerForm each time?
Should I just display data from the current customer bean rather than from customerForm?

Can anyone please help me out?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a "wizard" type workflow, I've found that putting the ActionForm in the session works well for me. Just make sure you remove it from the session when you're through with it.

Here is a link that will give you some more ideas about how to set up this type of workflow.

If I set to "session" then I can maintain the data across the various forms, but customerForm.reset() is still called.


If you have an ActionForm that is being populated across multiple pages, you don't want the reset() method to wipe out all the data in the form . Just don't put anythiing in that method, and create your own myReset() method that you call yourself only when you need to.
 
sudhakar kanagarajan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic