5

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
  • Show us your bean and markup! The exception is misleading. In most cases it is caused by not providing a collection for the value attribute of the datatable. Commented May 1, 2013 at 18:26

3 Answers 3

11

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() ); } 
Sign up to request clarification or add additional context in comments.

Comments

6

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)

1 Comment

Data Table is not displaying; please help. <p:panelGrid cellspacing="15" cellpadding="10" style="width:750px;"> <p:dataTable var="studyPlanList" value="#{editBean.lazyModel}" paginator="true" rows="10" paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" rowsPerPageTemplate="5,10,15" selectionMode="single" selection="" id="studyPlanTable"> <p:column headerText="StudyPlan" > <h:outputText value="#{studyPlanList.name}" /> </p:column> </p:dataTable> </p:panelGrid
0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.