Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to Autosave the changes when the page is changed?

 
shashank bezalwar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
I am doing pagination in jsp and here is my code for pagination:

----------------------------------------------------------------



---------------------------------------------------------------------------
I am retrieving 10 records per page passing the start value to servlet depending on which the servlet retrieves alues from database. Now my problem is i have to auto save the current page before moving to another page when i click on next or previous. Is there any way to do that?
thanks in advance

[BPSouther: Added code tags]
[ November 14, 2007: Message edited by: Ben Souther ]
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you are talking about saving to the backend, then you have to call a method that will do it when the button is clicked.
 
shashank bezalwar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to save the data to database. I am using two servlets one to retrieve the data from the db and another to save to db. In my pagination code i am retrieving data from database.The user can edit the data retrieved from db so i want to save the changes made by the user before going to next page to avoid loss of changes if the user accidently clicks on previous or next button.How to call both the servlets on single click?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no concept of "autoSave" in HTML, Servlets or JSP.

If you want to save changes while paging then you will need to modify your code to post all forms and do the writes while paging.
 
shashank bezalwar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you didnt got my problem. I am using anchor tag which calls the same jsp page with different start index so the user gets next 10 or previous 10 values. Till now i was calling one servlet when the user clicks on next or previous image. Now i want to call the same jsp page as well as servlet which saves the data of my current page to database. My problem is how to call the same jsp page and at the same time call servlet.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did understand your problem.

If you want to save the data on the current page when you move to the next page, you'll need to update your pages submit a form with the data from the current page when moving to the next (instead of using anchor tags).

This will probably also require that you re-work your servlet code so you can move to the next page after a form submission.
 
shashank bezalwar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your advice i will use form instead of anchor tags.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javaranch tip:

Code like this (with nested branch statements) is extremely difficult to read if it's not formatted correctly.

See this to learn how to wrap your code in UBB Code tags which will preserve your indenting, increasing the likelihood that someone will actually read it and help you in the future.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you are talking about saving to the backend, then you have to call a method that will do it when the button is clicked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic