diff --git a/src/main/java/org/primefaces/component/api/UIData.java b/src/main/java/org/primefaces/component/api/UIData.java
index <HASH>..<HASH> 100644
--- a/src/main/java/org/primefaces/component/api/UIData.java
+++ b/src/main/java/org/primefaces/component/api/UIData.java
@@ -150,13 +150,13 @@ public class UIData extends javax.faces.component.UIData {
 	}
     
     public void calculateFirst() {
-        int rows = this.getRowsToRender();
+        int rows = this.getRows();
         
         if(rows > 0) {
             int first = this.getFirst();
             int rowCount = this.getRowCount();
             
-            if(first >= rowCount) {
+            if(rowCount > 0 && first >= rowCount) {
                 int numberOfPages = (int) Math.ceil(rowCount * 1d / rows);
                 
                 this.setFirst((numberOfPages-1) * rows);
Fixed negative first in case rowCount is 0.