Forums Register Login

saving the details in when i click next and previous buttons

+Pie Number of slices to send: Send
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??
+Pie Number of slices to send: Send
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

+Pie Number of slices to send: Send
hi balram

can u elaborate bit more i didnt understand completely;
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
thank u for ur reply
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2646 times.
Similar Threads
After submit the link parameter get null
Table in Oracle to JTable
paging for dynamic rows
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:59:54.