Congratulations... PrimeFaces is a great work!
My code work fine on DataTable 2.x., with lazy loading, pagination, filter and sort... everything OK!
But on 3.x, i get a crash when using pagination, the records are not shown and in the console:
SEVERE: java.lang.IndexOutOfBoundsException: Index: 5, Size: 5
Anyone have any idea what could be?
The code's are:
Code: Select all
<p:dataTable onRowSelectComplete="#{..}"
onRowSelectUpdate="#{..}"
rowSelectListener="#{..}"
selection="#{..}"
value="#{menuBean.lista}"
dblClickSelect="true"
dynamic="true"
lazy="true"
selectionMode="single"
var="linha"
currentPageReportTemplate="#{dataTableBean.currentPageReportTemplate}"
emptyMessage="#{rotulosBean.pesquisaVazia}"
id="#{pesquisaMenusBean.idDataTable}"
paginator="#{dataTableBean.paginator}"
paginatorAlwaysVisible="#{dataTableBean.paginatorAlwaysVisible}"
paginatorPosition="#{dataTableBean.paginatorPosition}"
paginatorTemplate="#{dataTableBean.paginatorTemplate}"
rows="#{dataTableBean.rowsPerPage}"
rowsPerPageTemplate="#{dataTableBean.rowsPerPageTemplate}"
widgetVar="#{pesquisaMenusBean.idDataTable}" >
<p:column rendered="false">
<f:facet name="header">
<h:outputText value="ID" />
</f:facet>
<h:outputText value="#{linha.id}" />
</p:column>
<p:column sortBy="#{linha.descricao}" filterBy="#{linha.descricao}" filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="#{rotulosBean.descricao}" />
</f:facet>
<h:outputText value="#{linha.descricao}" />
</p:column>
<p:column sortBy="#{linha.caminho}" filterBy="#{linha.caminho}" filterMatchMode="contains" >
<f:facet name="header">
<h:outputText value="#{rotulosBean.caminho}" />
</f:facet>
<h:outputText value="#{linha.caminho}" />
</p:column>
<p:column sortBy="#{linha.raiz}" filterBy="#{linha.raiz}" filterMatchMode="contains" >
<f:facet name="header">
<h:outputText value="#{rotulosBean.raiz}" />
</f:facet>
<h:outputText value="#{linha.raiz}" />
</p:column>
</p:dataTable>
Code: Select all
@ManagedBean
@ViewScoped
public class MenuBean extends core.view.bean.MenuBean implements Serializable {
public MenuBean() {
super();
}
}
Code: Select all
public class MenuBean extends AbsManagedBean {
private MenusLazy<DummyMenu> lazyData;
:
:
public MenuBean() {
:
:
}
public MenusLazy<DummyMenu> getLista() {
if (lazyData == null) {
carregaLista();
}
return lazyData;
}
private void carregaLista() {
try {
lazyData = new MenusLazy<DummyMenu>();
lazyData.setPageSize(10);
} catch (Mensagem ex) {
addMensagem(ex);
}
}
}
Code: Select all
public class MenusLazy<DummyMenu> extends LazyDataModel<DummyMenu> {
private Map mapa;
private CoreHelper core;
public MenusLazy() throws Mensagem {
super();
mapa = new HashMap();
mapa.put("first", 0);
mapa.put("pageSize", 10);
mapa.put("sortField", null);
mapa.put("sortOrder", null);
mapa.put("filters", new HashMap<String, String>());
core = new CoreHelper();
Map retorno = core.getMenusLazy(mapa);
Long count = (Long) retorno.get("count");
this.setRowCount(count.intValue());
}
@Override
public List<DummyMenu> load(int first, int pageSize, String sortField, boolean sortOrder, Map<String, String> filters) {
List<DummyMenu> lista = new ArrayList<DummyMenu>();
mapa = new HashMap();
mapa.put("first", first);
mapa.put("pageSize", pageSize);
mapa.put("sortField", sortField);
mapa.put("sortOrder", sortOrder);
mapa.put("filters", filters);
try {
Map retorno = core.getMenusLazy(mapa);
lista = (List<DummyMenu>) retorno.get("lista");
Long count = (Long) retorno.get("count");
this.setRowCount(count.intValue());
} catch (Mensagem ex) {
} finally {
return lista;
}
}
}