Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

next and prev functionality

 
Anu Pasricha
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am converting a Visual Basic project into servlets. In that i have a form with next, previous, add delete etc. How should i write the functionality for next anmd previous. How do i get to know on which record next is clicked.
I am calling the same servlet on click of buttons.
Bye
Regards
Anu
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just put a hidden variable in your form so you can find out where the request is coming from. Hidden variables are very handy for this sort of problem.
Bill
 
peter greaves
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as bill says, you need to maintain client state across http which is a stateless protocol. the state you need is two fold:
1. what is the current record?
2. what is the direction (next or previous)?
you have a number of choices for either of these:
1. as bill says, use the hidden field in the html page - you will need a <form> for this and you might not be generating one if your data is r/only.
2. use the query string and analyse this in doGet of the servlet to determine the direction of travel and the current pos e.g.
http://foo/.com/servlet/MyServlet?dir=next&rec=092302
where dir is either "next" or "prev", and rec is something that identifies the current record. something like this should work for you.
3. cookies - store the info in a cookie. a bit messy and i would avoid it.
hope this helps,
peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic