| Author |
saving the details in when i click next and previous buttons
|
kesava chaitanya
Ranch Hand
Joined: Aug 15, 2001
Posts: 140
|
|
hi in my application i have one scenario like this i will create 3 rows like this eno ename sal textbox textbox textbox textbox textbox textbox textbox textbox textbox Next eno ename sal textbox textbox textbox textbox textbox textbox textbox textbox textbox Previous i will enter details in textboxes and then i will click next button i will call same page again this time i will enter details in 3 rows again like i did previously this time i will put Previous button when i click previous button The details be populated in the first that i have entered in the first page and when i click next button the details should be displayed that i have entered in the second page; How can i do this any idea??
|
 |
Balan Raj
Ranch Hand
Joined: Aug 26, 2003
Posts: 74
|
|
Name your textboxes in a fashion that they do not over-write when the pages change. Prefix the page number to the fields, so on submit, u can submit the form & the bean can save it in some data structure & store it in session with the key as the page number. when u get back to the page, try to see if the session has the value for a given page number, if yes, get the values & populate the text fields, if not, show them blank doesnt seem too complicated for me
|
 |
kesava chaitanya
Ranch Hand
Joined: Aug 15, 2001
Posts: 140
|
|
hi balram can u elaborate bit more i didnt understand completely;
|
 |
Balan Raj
Ranch Hand
Joined: Aug 26, 2003
Posts: 74
|
|
Donno which part was unclear, I'll try to restate what I said,probably with more clarity
Name your textboxes in a fashion that they do not over-write when the pages change. Prefix the page number to the fields, so on submit, u can submit the form & the bean can save it in some data structure & store it in session with the key as the page number.
In your JSP, make sure the text boxes are not having harcoded names. They would look something like : When you submit the form, in your bean you will iterate throught the request & collect the matrix of the form data into some kind of 2 dimensional array. String pageNumber = request.getParameter("pageNumber"); String rows= request.getParameter("rows"); String cols= request.getParameter("cols"); //NOTE : convert row & col to integers iterate rows : iterate cols : formData[rowItr][colItr] = request.getParameter("mytextbox+<%=row+col+"_"+pageNumber%>"); So u loop thru & get all the form elements into the 2d array. Now put that into session, with a simple session.putValue("myFormDataForPage"+pageNumber, formData); Now, comes the intersting part of setting the values.. your form will post to itself, with the correct pageNumber incremented or decremented. So, I will rewrite my input box with something like Well, hope this helps
|
 |
kesava chaitanya
Ranch Hand
Joined: Aug 15, 2001
Posts: 140
|
|
|
thank u for ur reply
|
 |
 |
|
|
subject: saving the details in when i click next and previous buttons
|
|
|