2
I have an delete button that sits inside a column of dataTable
and when I click on the same the method that is responsible for the user’s deletion 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 on 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 scope of the MB is @SessionScoped
actionListener="#{usuarioBean.excluir(usuario}
is missing a ) , put and forehead again.– Wellington Avelino
It was an error in the question only, the code was right and yet the method is not being called
– DiegoAugusto
tried to add process="@this" to the button?
– Rafael
I’m using
BootsFaces
no process to put on buttons– DiegoAugusto
This component is within the same form?
– paulohddias
Yes, I tried everything and could not solve I think it is a problem with Bootsfaces
– DiegoAugusto
Because when I use Primefaces it works
– DiegoAugusto
@Diegoaugusto, already tried to use only action?
– Marcos Sousa
Put ajax=false in commandButton.
– Roknauta
@Douglas If you want to answer, this is a solution. I had forgotten to answer this question after troubleshooting the error
– DiegoAugusto