Maintaining form data across pages...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jeff_Sprenger
Posted On:   Thursday, January 31, 2002 08:00 AM

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 , 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 a   More>>

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 , 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?

  • Jeff.

       <<Less

    Re: Maintaining form data across pages...

    Posted By:   Jason_Rosenblum  
    Posted On:   Thursday, January 31, 2002 04:57 PM

    here's an example:
    you have an HTML form. after it is filled out the user previews the results on a second JSP and then chooses to submit or edit the HTML form again. If the user submits, then he is forwarded to a confirmation page.

    In order to process this you do:
    1) cache ActionForm in session after form submission.
    2) I pass my Customer bean to the preview page via request. I was able to construct a Customer bean by calling a toXXXX() method in my ActionForm (e.g. toCustomer).
    3) on the confirmation page i query the database and return the results as a Customer bean passed via request. I also clean out session using removeAttribute().

    I hope that helps...
    About | Sitemap | Contact