Update the database correctly

Asked

Viewed 362 times

4

Updated: Link with a video that better exemplifies the situation.


I have a big problem, I’m having difficulties to update the database and display the updated data in 2 DataTables different.

I have two pages, one is only visible to office worker Liberacao and the other pro cargo Auditor

Page of the Liberation: inserir a descrição da imagem aqui

Page of the Auditor inserir a descrição da imagem aqui

I have a button grabs the selected object in each row. It opens a Dialog which is carried by Bean. On this page that opens I have the button Enviar auditoria and Concluir Auditoria When I Send the Audit it is edited in the database with the cargo who sent it and the status awaiting.

On the Release page in the table Auditorias Recebidas is listed only what was sent by Auditor and has the status Aguardando. And on the Auditor’s page in "Received Audits is only listed what was sent by Liberação and the status for Aguardando.

The problem is as follows, when I have just performed a sending operation and return to the table even after pressing F5 several times the table does not update every time, sometimes it updates and sometimes not. I would like help to be able to update the database correctly:

Here is my method that does the research and fills my List on the Auditor screen:

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 "Aguardando" faz a pesquisa.
            list = solicitacaoDAO.listarPorUsuario("Liberacao", "Aguardando");


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

        }
    }
}

} And here’s the Liberation screen:

@ManagedBean(name = "controleAuditoriaLibBean")
@ViewScoped
public class ControleAuditoriaLiberacaoBean {
    private List<SolicitacoesBD> list;
    private List<SolicitacoesBD> listFiltrada;
    @PostConstruct
    public void carregarPesquisa(){
        try{
            SolicitacoesDAO solicitacaoDAO = new SolicitacoesDAO();
            list = solicitacaoDAO.listarPorUsuario("Auditor", "Aguardando");
            carregarEnviados();
        }catch(RuntimeException ex){
            FacesUtil.adicionarMsgErro("Erro ao tentar listar as Auditorias");
        }
    }
}

Method carrying the Auditor’s Mailed List, the Release is similar:

// mostra na tabela de baixo todos os dados enviados
    public void carregarEnviados() {
        try {
            SolicitacoesDAO solicitacaoDAO = new SolicitacoesDAO();
            listEnviados = solicitacaoDAO.listarEnviados("Auditor");

        } catch (RuntimeException ex) {
            FacesUtil.adicionarMsgErro("Erro ao tentar listar as Auditorias");
        }
    }

Updated

Doing some tests I realized that the list is not loaded "immediately" with the database data, it takes around 15 seconds until the list is filled with the current data, even the @postConstruct and the <f:event> with preRenderView does not update the table immediately. And yet I still can’t find where the problem is.

  • How’s the page code? I’ve had a similar mt problem using RichFaces that would solve using the ReRender correctly

  • How you populate the listEnviados?

  • I will edit the question and put the method.

  • I did a test and if I wait about 20 seconds after the action and give an update the datatable updates correctly, IE, the line that was sent disappear, but only after 20, 25 seconds

  • I edited the question, I have a method of this in each bean, the only difference is in this line listEnviados = solicitacaoDAO.listarEnviados("Auditor"); that changes to Liberacao on the release screen

  • Dude already had a problem with primefaces because of the browser cache. Try to clean up. And try adding a process="@this" and update to the table buttons.

  • all right, I’ll try

  • Didn’t work :/

  • 1

    @Can Techies post xhtml? You checked and the value is correctly persisted in the bank right after the right confirmation?

  • Why don’t you put Controleauditoriaauditorbean as Requestscope? Have you debugged to see if the Controlauditorbean Search is called when sending an audit? Can be a simple ajax problem / request.

  • I tried, but the select button inside my datatable didn’t work. The only way to solve the problem I found was to make the "Sent" table on another screen. Now it’s worked

  • I know it has nothing to do with it but, which name of this template you’re using?

Show 7 more comments

1 answer

0


I tried several things and nothing went right, the only solution I found that worked was to take the dataTable Audits Sent from the same page as received and created a Bean separate to manage these pages. I don’t know why but it worked.

UPDATED The problem was solved with only one commit in the method that does the research, before I did not commit the bank queries.

Browser other questions tagged

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