Hi,
I am new to
java and am trying to create a
jsp page with prev/next buttons that show each individual record in an arrayList. My previous button works like it should be the next button but I get errors if I try to reverse the syntax. I really need help! My code is below. Thanks all!
int agreementIndex = 0;
int nextIndex = 0;
int previousIndex = 0;
agreements = (ArrayList)session.getAttribute("agreements");
if (agreements == null) {
}
request.setAttribute("agreements", agreements);
if (request.getParameter("agreementIndex") != null) {
agreementIndex = Integer.parseInt(request.getParameter("agreementIndex"));
}
Agreement agreement = (Agreement)agreements.get(agreementIndex);
if ((agreementIndex+1) >= agreements.size()) {
nextIndex = -1;
} else {
nextIndex = agreementIndex++;
}
if ((agreementIndex-1) < 0) {
previousIndex = -1;
} else {
previousIndex = agreementIndex--;
}