wood burning stoves*
The moose likes Struts and the fly likes Maintaining form data across pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Maintaining form data across pages" Watch "Maintaining form data across pages" New topic
Author

Maintaining form data across pages

Sudhakar k Kanagarajan
Greenhorn

Joined: May 15, 2006
Posts: 1
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

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
sudhakar kanagarajan
Greenhorn

Joined: Nov 14, 2005
Posts: 5
Thank you very much
 
 
subject: Maintaining form data across pages