Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Keeping form input values

Reply
Thread Tools

Keeping form input values

 
 
francan00@yahoo.com
Guest
Posts: n/a
 
      02-19-2008
I am going to create a form that will have about 3 pages of inputs in
one form.
The first and second page will have continue button and the final page
(3rd page) will have the submit (into database) button.

What is the best way to forward the form inputs from each page so all
will be submitted?

I will use MVC architecture but dont have Struts on our Tomcat 4.1.27
container.
 
Reply With Quote
 
 
 
 
Wojtek
Guest
Posts: n/a
 
      02-19-2008
wrote :
> I am going to create a form that will have about 3 pages of inputs in
> one form.
> The first and second page will have continue button and the final page
> (3rd page) will have the submit (into database) button.
>
> What is the best way to forward the form inputs from each page so all
> will be submitted?


Create an object which will hold all the form inputs, and store that
object in the user's session. You can also store state, so you know if
the user clicks on the Back button, or tries to go to page two without
first going to page one.

--
Wojtek


 
Reply With Quote
 
 
 
 
francan00@yahoo.com
Guest
Posts: n/a
 
      02-20-2008
On Feb 19, 3:11*pm, Wojtek <nowh...@a.com> wrote:
> franca...@yahoo.com wrote :
>
> > I am going to create a form that will have about 3 pages of inputs in
> > one form.
> > The first and second page will have continue button and the final page
> > (3rd page) will have the submit (into database) button.

>
> > What is the best way to forward the form inputs from each page so all
> > will be submitted?

>
> Create an object which will hold all the form inputs, and store that
> object in the user's session. You can also store state, so you know if
> the user clicks on the Back button, or tries to go to page two without
> first going to page one.
>
> --
> Wojtek


Thanks, I assume I can create an object using JavaBean class where I
will take all the fields (via getter and setter methods) and use a
special method to grab all the fields into one object. Then call that
special method in my Servlet?
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      02-20-2008
wrote:
> I assume I can create an object using JavaBean class where I
> will take all the fields (via getter and setter methods) and use a
> special method to grab all the fields into one object. Then call that
> special method in my Servlet?


That's one way, although you don't really need any method more special than
doPost(), unless things get large enough to refactor.

You could also, for example, use the ServletRequest method getParameterMap()
and work directly off the Map of parameters:
<http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParameterMap()>

This has the advantage of grabbing all the parameters in one fell swoop, and
the disadvantage of leaving all the parameter values as unvalidated Strings
packaged in the String [] values of the Map.

--
Lew
 
Reply With Quote
 
Wojtek
Guest
Posts: n/a
 
      02-20-2008
fr-) wrote :
> On Feb 19, 3:11*pm, Wojtek <nowh...@a.com> wrote:
>> franca...@yahoo.com wrote :
>>
>>> I am going to create a form that will have about 3 pages of inputs in
>>> one form.
>>> The first and second page will have continue button and the final page
>>> (3rd page) will have the submit (into database) button.
>>> What is the best way to forward the form inputs from each page so all
>>> will be submitted?

>>
>> Create an object which will hold all the form inputs, and store that
>> object in the user's session. You can also store state, so you know if
>> the user clicks on the Back button, or tries to go to page two without
>> first going to page one.
>>
>> --
>> Wojtek

>
> Thanks, I assume I can create an object using JavaBean class where I
> will take all the fields (via getter and setter methods) and use a
> special method to grab all the fields into one object. Then call that
> special method in my Servlet?


Well, you CAN use a bean, but a simple class will also do. Extracting
form fields from the request is not all that difficult, and it lets you
condition the information, for things like valid input, ie: all numbers
for a numeric value, and within bounds, so that month value is within
1 and 12 inclusive.

NEVER assume that the user is kind enough to always enter valid values


--
Wojtek


 
Reply With Quote
 
francan00@yahoo.com
Guest
Posts: n/a
 
      02-20-2008
Thanks Lew and Wojtek!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keeping track of the N largest values Roy Smith Python 11 12-31-2010 10:52 PM
Radio buttons not keeping values in DataGrids tshad ASP .Net 0 09-13-2008 06:58 AM
Keeping Values of a Form =?Utf-8?B?QmFkaXM=?= ASP .Net 2 12-05-2006 08:24 AM
User Controls not keeping property values David Lozzi ASP .Net 7 12-20-2005 03:18 PM
Keeping VoIP calls up while high IP Input process cpu time Brian McCrary Cisco 2 07-01-2005 02:38 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57