I am having problems updating a dataTable primafaces after doing a search with filterBy. First, I do a search through a method in the Managedbean to bring the list from the database to the table. So, I search through a column using the filterBy attribute. After that, when I do another search for the managedbean the list of results in the dataTable is no longer updated, the same results from the previous search remain.
Below the search button:
<p:commandButton value="Pesquisar"
actionListener="#{notificacaoManagedBean.filtrarNotificacoes()}"
update=":form:formAlarmesEventos:listaNotificacao"
ajax="true"
process="@all"
icon="ui-icon-search">
</p:commandButton>
The dataTable:
<p:dataTable
widgetVar="dataTableNotificacao"
value="#{notificacaoManagedBean.notificacoes}"
var="notificacao"
id="listaNotificacao"
paginator="true"
rows="10"
rowsPerPageTemplate="5, 10, 15, 20, 30, 50, 100"
emptyMessage="Nenhuma notificação foi registrada."
style="width: 100%" >
<f:facet name="header">Lista de Notificações</f:facet>
<p:column headerText="Hora e Data">
<h:outputText value="#{notificacao.dataHora}">
<f:convertDateTime pattern="HH:mm:ss - dd/MM/yyyy" />
</h:outputText>
<ui:remove>
<h:outputText value="#{notificacao.dataHora}" styleClass="dataInibida">
<f:convertDateTime locale="pt_BR" />
</h:outputText>
</ui:remove>
</p:column>
<p:column width="8%" filterBy="#{notificacao.tipo}" headerText="Tipo" filterMatchMode="exact">
<f:facet name="filter" >
<p:selectOneMenu id="selectTipo" onchange="PF('dataTableNotificacao').filter()" >
<f:selectItem itemLabel="Tudo" itemValue="#{null}" />
<f:selectItem itemValue="Evento" itemLabel="Eventos" />
<f:selectItem itemValue="Alarme" itemLabel="Alarmes" />
</p:selectOneMenu>
</f:facet>
<h:outputText id="map" value="#{notificacao.tipo}" />
</p:column>
<p:column headerText="Tag" filterBy="#{notificacao.tag}" >#{notificacao.tag}</p:column>
<p:column headerText="Operador" filterBy="#{notificacao.operador}" >#{notificacao.operador}</p:column>
<p:column headerText="Computador">#{notificacao.computador}</p:column>
<p:column headerText="Valor Anterior" width="7%" >#{notificacao.valorAnterior}</p:column>
<p:column headerText="Valor Atual" width="7%" >#{notificacao.valorAtual}</p:column>
</p:dataTable>
The method that filters the search:
public void filtrarNotificacoes(){
notificacoes = new ArrayList<>();
notificacao = new Notificacao();
Date inicio = DateHelper.unirDataHora(dataInicial, horaInicial);
Date fim = DateHelper.unirDataHora(dataFinal, horaFinal);
notificacoes = service.obterNotificacoes(
new DateHelper(inicio),
new DateHelper(fim));
}