DataTable - Lazy Loading Primefaces showing error

2020-07-13 06:45发布

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.

3条回答
放我归山
3楼-- · 2020-07-13 07:19

This answer is derivative to Alfaville's answer, but if you happen to have set a field named pageSize in your LazyDataTable descendant it may cause the same problem. This was the case with me and I didn't see the problem until I saw the Override of setRowIndex.

查看更多
相关推荐>>
4楼-- · 2020-07-13 07:23

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() );
}
查看更多
登录 后发表回答