Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataTable - Lazy Loading Primefaces showing error

I am using JSF2.0 with PrimeFaces3.1 and Spring3.1 for Business logic.I was trying to use a DataTable- Lazy loading. But It is giving me the following error. Kindly help.

An Error Occurred:

/ by zero
- Stack Trace
java.lang.ArithmeticException: / by zero
at org.primefaces.model.LazyDataModel.setRowIndex(LazyDataModel.java:62)
at javax.faces.component.UIData.setRowIndex(UIData.java:448)
at javax.faces.component.UIData.visitColumnsAndRows(UIData.java:1544)
at javax.faces.component.UIData.visitTree(UIData.java:1212)

Please help.
like image 429
user1281029 Avatar asked Apr 17 '12 05:04

user1281029


1 Answers

You must override the method setRowIndex

Example:

@Override
public void setRowIndex( int rowIndex ) {

   if ( rowIndex == -1 || getPageSize() == 0 ) {
    super.setRowIndex( -1 );
   } else
    super.setRowIndex( rowIndex % getPageSize() );
}
like image 118
Alfaville Avatar answered Sep 28 '22 11:09

Alfaville