Delete method is not called when I click on a commandButton

1

I have a delete button that is inside a column of dataTable and when I click on it the method that is responsible for the deletion of the user is not called.

dataTable:

<p:dataTable value="#{usuarioBean.listaUsuario}" id="usuarioTable"
var="usuario" style="" emptyMessage="Nenhuma Usuário Encontrado. "
rows="5" paginator="true" paginatorPosition="bottom">

Delete button:

<b:commandButton icon="glyphicon glyphicon-remove" value=""
look="danger" style="margin-left:10px" ajax="true"
update="frmPrin" title="Excluir" actionListener="#{usuarioBean.excluir(usuario)}">
</b:commandButton>

Delete method in MB:

public void excluir(Usuario usuario) {
        System.err.println("Metodo Excluir");

        try {
            UsuarioDAO usuarioDAO = new UsuarioDAO();
            usuarioDAO.excluir(usuario);

            FacesUtil.adicionarMsgInfo("Usuario excluido com sucesso");
            usuario = new Usuario();
            listarUsuarios();
        } catch (RuntimeException e) {
            FacesUtil.adicionarMsgErro("Erro ao excluir usuário");
            e.printStackTrace();
        }
    }

Exclude method in DAO:

public void excluir(Usuario usuario) {
        System.out.println("<METODO EXCLUIR CHAMADO");
        Session sessao = HibernateUtil.getSessionFactory().openSession();
        Transaction transacao = null;
        try {
            transacao = sessao.beginTransaction();
            sessao.delete(usuario);
            transacao.commit();
        } catch (RuntimeException ex) {

            throw ex;
        } finally {
            sessao.close();
        }
    }

The MB scope is @SessionScoped

    
asked by anonymous 30.07.2015 / 21:07

1 answer

0

On your commandButton change ajax :

ajax="false"
    
09.02.2017 / 20:50