This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am using Struts 1.1. I need to implement a multipage form for my functionality which caters to add and modify. I need to use the same jsps, ActionForm and Action class to handle add as well as modify. On each page/ form, there will be a set of fields which the user will need to fill. Only on the last page (say 5th page) after final submit, the data (collected from each page) has to be either added or updated as appropriate in the database. I am able to handle validation in my ActionForm for each page submit. My question is
1. Other than implementing this by setting scope = session in action mapping of struts-config xml or passing fields of each page into the next subsequent page (via hidden fields), is there any other way of implementing this ?? Can i still retain the form data through subsequent pages ??
Originally posted by lavi per: Other than implementing this by setting scope = session in action mapping of struts-config xml or passing fields of each page into the next subsequent page (via hidden fields), is there any other way of implementing this ??
Either of these methods will accomplish what you want, and these are the best two methods that I can think of. Why do you need another way to do it?
Thank you for your response. Its been decided not to use session since its already overused in the project and they don't way to further overburden it. The other option could be via html hidden fields, but this would be an unclean way of doing it as well as cause maintainability issues. I was wondering if there is another approach to handling multi-page form data, such that i am able to access fields corresponding to the first page even on subsequent pages as well as the final page which finally adds the data in the database.
Joined: Feb 15, 2005
There's no magic bullet. Either deal with the messiness of hidden fields or use the HTTPSession. In my experience, as long as you clean up after yourself (Meaning remove objects from the session when you're done with them) using the HTTPSession isn't really a big performance problem, especially with today's App Servers. The only exception to this is if you're working on a site that expects thousands of users per minute.
Joined: Apr 24, 2002
Thanks Merrill once again for your help and inputs. We have decided to go ahead and use session scope for the multipage form bean in struts-config (action tag).