DataTable - Lazy Loading Primefaces showing error

二次信任 提交于 2019-12-06 02:34:20

问题


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.

回答1:


Its seems like a know issue

datatable: java.lang.ArithmeticException: / by zero

Issue 1544: LazyDataTable.setRowIndex throws arithmetic exception: division by 0.


It has a FIX/WORKAROUND (so claimed by some user)




回答2:


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() );
}



回答3:


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.



来源:https://stackoverflow.com/questions/10185560/datatable-lazy-loading-primefaces-showing-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!