I am using Primefaces 5.2.
and I have a tabview
Dinamic
and inside every Tab
created, a DataTable
. After I sort a column, or do any pagination action on the table and change from Tab
, I come up with the following nullpointer
:
java.lang.NullPointerException at org.primefaces.component.datatable.DataTable.findColumnInGroup (DataTable.java:905) at org.primefaces.component.datatable.DataTable.findColumn (DataTable.java:896) at org.primefaces.component.datatable.DataTable.getSortColumn (DataTable.java:1401) at org.primefaces.component.datatable.DataTable.resolveSortField (DataTable.java:1020) at org.primefaces.component.datatable.DataTable.loadLazyData (DataTable.java:972) at org.primefaces.component.datatable.DataTableRenderer.preRender (DataTableRenderer.java:95) at org.primefaces.component.datatable.DataTableRenderer.encodeEnd (DataTableRenderer.java:83)
By debugging source
of primefaces
, I checked that the findColumnInGroup
method is looking for the column in Tab
Wrong.
Example: When I change from Tab 0
to Tab 2
in my TabView
, and do any select action on my DataTable
, it looks for a column with id: Tabview2:blabla
, but when I sort and mute to Tab 1
, it is looking for the column with id
Tabview0:blabla
, it's like Tab
to go back to 0 .
Another problem I encountered is that when I change from Tab
, my DataTable
is not returning to the initial state. Have you ever come across this ?
<p:tabView dynamic="true" cache="true" tabindex="#{VMConflito.indexTabConflitos}" widgetVar="tabView" id="tabView" value="#{VMConflito.totalConflitos}" var="tc">
<p:ajax event="tabChange" listener="#{VMConflito.buscarConflitos(tc)}" update="@this" />
<p:tab title="#{tc.entidade} (#{tc.totalConflitos})" >
<p:dataTable id="tabela" emptyMessage="sem registros" lazy="true" value="#{VMConflito.conflitos}" var="conflito"
paginator="true" paginatorPosition="bottom" rows="10" paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="10, 20, 30" selectionMode="single" styleClass="tabela-cor" rowKey="#{conflito.id}">
<p:column headerText="ID" sortBy="#{conflito.id}">
<h:outputLabel value="#{conflito.id}" />
</p:column>
<p:column headerText="instante do conflito" sortBy="#{conflito.instanteConflito}">
<h:outputLabel value="#{conflito.instanteConflito}" >
<f:converter converterId="localDateTime" />
</h:outputLabel>
</p:column>
<p:column headerText="similaridade calculada" sortBy="#{conflito.similaridade}">
<h:outputLabel value="#{conflito.similaridade}" />
</p:column>
<p:column headerText="id criado">
<h:outputLabel value="#{conflito.entidadeId}" />
</p:column>
<p:column headerText="id candidato">
<h:outputLabel value="#{conflito.conflitoId}" />
</p:column>
<p:column style="width: 70px!important;" >
<p:commandButton value="Ver" styleClass="cores-claras" >
<p:ajax event="click"
update="painel" listener="#{VMConflito.setConflito(conflito)}" />
</p:commandButton>
</p:column>
</p:dataTable>
</p:tab>
</p:tabView>