From 8607ee07338d95b467b7e72bb5f6d6f77b5cc595 Mon Sep 17 00:00:00 2001 From: zapata Date: Tue, 21 Jan 2003 18:32:03 +0000 Subject: [PATCH] slightly improved the way next/prev page was determined. --- source/mircoders/servlet/ServletModuleOpenIndy.java | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/source/mircoders/servlet/ServletModuleOpenIndy.java b/source/mircoders/servlet/ServletModuleOpenIndy.java index 58a79a63..93fe4d54 100755 --- a/source/mircoders/servlet/ServletModuleOpenIndy.java +++ b/source/mircoders/servlet/ServletModuleOpenIndy.java @@ -87,7 +87,7 @@ import mircoders.search.*; * open-postings to the newswire * * @author mir-coders group - * @version $Id: ServletModuleOpenIndy.java,v 1.56 2003/01/21 18:03:09 zapata Exp $ + * @version $Id: ServletModuleOpenIndy.java,v 1.57 2003/01/21 18:32:03 zapata Exp $ * */ @@ -616,21 +616,22 @@ public class ServletModuleOpenIndy extends ServletModule if (searchBackValue != null){ int totalHits = ((Integer) session.getAttribute("numberOfHits")).intValue(); int newPosition=((Integer)session.getAttribute("positionInResults")).intValue()-increment; - if (newPosition < 0 || newPosition >= totalHits){ - throw new ServletModuleUserException("newPosition: index out bounds, value was:"+(new Integer(newPosition)).toString()); - } + if (newPosition<0) + newPosition=0; + if (newPosition >= totalHits) + newPosition=totalHits-1; session.setAttribute("positionInResults",new Integer(newPosition)); - } else { if (searchForwardValue != null){ int totalHits = ((Integer) session.getAttribute("numberOfHits")).intValue(); int newPosition=((Integer)session.getAttribute("positionInResults")).intValue()+increment; - if (newPosition < 0 || newPosition >= totalHits){ - throw new ServletModuleUserException("newPosition: index out bounds, value was:"+(new Integer(newPosition)).toString()); - } - session.setAttribute("positionInResults",new Integer(newPosition)); + if (newPosition<0) + newPosition=0; + if (newPosition >= totalHits) + newPosition=totalHits-1; + session.setAttribute("positionInResults",new Integer(newPosition)); } else { String indexPath=MirConfig.getProp("IndexPath"); @@ -794,7 +795,7 @@ public class ServletModuleOpenIndy extends ServletModule if (!(pIR+increment>=numHits)){ mergeData.put("hasNext","y"); } - if (pIR-increment>=0){ + if (pIR>0){ mergeData.put("hasPrevious","y"); } -- 2.11.0