I am trying to implement a table with lazy loading. I think I have all the steps from the demo page and the documentation, but I always get the message “No entries”. I think I reduced the code to a minimun expression, at least there should be one entry:
Table:
<h:form id="listaEmpresas">
<p:dataTable id="tablaEmpresas" value="#{empresasTableMB.lazyDataModel}" var="empresa">
<p:column>
<f:facet name="header">
<h:outputText value="#{msgs.empresa_tabla_nombre}"/>
</f:facet>
<h:outputText value="#{empresa.nombre} "/>
</p:column>
</p:dataTable>
</h:form>
LazyDataModel:
@Override
public List<Empresa> load(int first, int pageSize, String sortField, SortOrder so, Map<String, String> filters) {
List<Empresa> listaEmpresas = new ArrayList();
Empresa e = new Empresa();
e.setNombre("Company");
listaEmpresas.add(e);
this.setRowCount(1);
return listaEmpresas;
}
@Override
public void setRowIndex(int rowIndex) {
if (rowIndex == -1 || getPageSize() == 0) {
super.setRowIndex(-1);
}
else
super.setRowIndex(rowIndex % getPageSize());
}
I have to override setRowIndex or get the exception "java.lang.ArithmeticException: / by zero". I am using primefaces-3.1-SNAPSHOT, jsf 2.0.3 and tomcat 6.0. Please help. What am I missing?
source
share