Small change to handle target record with low row number
authorMartin Taal <martin.taal@openbravo.com>
Tue, 14 Dec 2010 16:08:57 +0100
changeset 9130 382532ad542b
parent 9129 dad0e6a90725
child 9131 1fee5f946d34
Small change to handle target record with low row number
modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Tue Dec 14 15:58:42 2010 +0100
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Tue Dec 14 16:08:57 2010 +0100
@@ -160,8 +160,13 @@
           final String targetRecordId = parameters.get(JsonConstants.TARGETRECORDID_PARAMETER);
           targetRowNumber = queryService.getRowNumber(targetRecordId);
           if (targetRowNumber != -1) {
-            queryService.setFirstResult(targetRowNumber);
             startRow = targetRowNumber;
+            // if the startrow is really low, then just read from 0
+            // to make sure that we have a full page of data to display
+            if (startRow < (computedMaxResults / 2)) {
+              startRow = 0;
+            }
+            queryService.setFirstResult(startRow);
           }
         }