This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to split a long form to forms ?  RSS feed

 
majid nakit
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to collect some data from the user, so I want the user start step one by filling up a form when she submit she will go to step two,..until the last step, could you please give me an example on how to do it.
thank you.
[ August 23, 2005: Message edited by: Bear Bibeault ]
 
Daniel Rhoades
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Separate the form elements into logical pages, at each step save the form parameters in a Map, add that Map to the session, then when the final step has been submitted read out that Map from the session and do something with it.

In a nutshell thats about it... there are probably many other ways to do it, but here is one for starters
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How you do something like this depends on your requirements.

Do you want people to be able to leave a partially filled out form and come back to it another day? If so, then saving the pages in session won't work. You'll need to write them to your database.

If they are to fill the entire thing out in one sitting, using session as Daniel mentioned could be the easiest way.
 
majid nakit
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Daniel,
I am new to this, I have never used Map in jsp, could you please give me a small example.
thanks.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a JSP with scriptlets, you can use Maps in exactly the same way as plain java. Just remember that they're stored in the session.

<% Map m = (Map)session.getAttribute("myMap");
m.put("inputName", inputValue);
%>

If you're using scriptless JSPs, you can either use beans or store the values in the map inside a servlet before forwarding to the next JSP.

-Yuriy
[ August 24, 2005: Message edited by: Yuriy Zilbergleyt ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using scriptless JSPs ...


Nothing prevents the use of Maps or the session when writing scriptless JSPs.

Another approach I've seen used is to carry all the values from page to page via hidden inputs. Much wordier and messier than the session mechanism, but another possibility.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing prevents the use of Maps or the session when writing scriptless JSPs.


My bad, forgot all about the <c:set> tag. I guess this is what happens when you only use scriptless JSPs when studying for the certification exam...

-Yuriy
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!