Datatable does not update immediately after "action"

Asked

Viewed 531 times

1

I have a DataTable with some data when I select a table row and click on finish process that row is saved in my database with the status Finalizado and the Cargo user logged in but this row only disappears from my table after several F5or else if I leave and enter the table again. I am loading the data into the table through this method:

@ManagedBean(name = "controleAuditoriaBean")
@ViewScoped
public class ControleAuditoriaAuditorBean {
private List<SolicitacoesBD> list;
private List<SolicitacoesBD> listEnviados;
@PostConstruct
    public void carregarPesquisa() {

        try {
            SolicitacoesDAO solicitacaoDAO = new SolicitacoesDAO();
            //Se o cargo for "Liberacao" e o Status for "finalizado" faz a pesquisa.
            list = solicitacaoDAO.listarPorUsuario("Liberacao", "Finalizado");


            System.out.println("Caminho: "+solicitacoesBD.getCaminhoArquivo());
        } catch (RuntimeException ex) {

        }
    }
}

I’m using ViewScoped in that bean.

And that’s how my datatable starts:

<p:dataTable id="tblAudAud" emptyMessage="Nenhum registro encontrado"
                var="controleAuditoria" value="#{controleAuditoriaBean.list}"
                filteredValue="#{controleAuditoriaBean.listFiltrada}" rows="10"
                paginator="true" style="margin-top: 5px;"
                rowKey="#{controleAuditoria.codigoBeneficiario}">

Can it be the system that is heavy? That’s why it doesn’t update?

1 answer

3

You have to clear your list because with the @ViewScoped the bean is maintained until the application navigates to another page, and depending on how you navigate it does not wipe the data.

  • understand and how I clear the list?

  • You can simply remove the element from the list. For example: lista.remove(itemSelecionado).

  • It didn’t work, I made some changes now to update the table I have to perform the same action twice. Let’s say I have three items on the table, I finish first and second when I get to third I have to finish it 2x. Always the last action has to be performed twice

Browser other questions tagged

You are not signed in. Login or sign up in order to post.