Pessoal, estou conseguindo listar os objetos do meu banco, mysql, mas quando clico no link para excluir não acontece nada!
Alguém poderia me dá uma ajuda?
segue os meu códigos:
quando tento deletar aparece isso:
INFO: building session factory
25/02/2011 20:45:51 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Hibernate:
select
this_.id_paciente as id1_17_0_,
this_.bairro_acomp as bairro2_17_0_,
this_.bairro_paci as bairro3_17_0_,
this_.cor_acomp as cor4_17_0_,
this_.cor_paci as cor5_17_0_,
this_.cpf_acomp as cpf6_17_0_,
this_.cpf_paci as cpf7_17_0_,
this_.data_nas as data8_17_0_,
this_.data_nasacomp as data9_17_0_,
this_.nome_acomp as nome10_17_0_,
this_.nome_paci as nome11_17_0_,
this_.numero_acomp as numero12_17_0_,
this_.numero_paci as numero13_17_0_,
this_.rg_acomp as rg14_17_0_,
this_.rg_paci as rg15_17_0_,
this_.rua_acomp as rua16_17_0_,
this_.rua_paci as rua17_17_0_,
this_.sexo_acomp as sexo18_17_0_,
this_.sexo_paci as sexo19_17_0_
from
paciente this_
Agora o código do Dao
public class Dao<T> {
private Class persistentClass;
protected Session session;
protected Session getSession(){
return session;
}
public Dao(Session session, Class persistentClass){
this.session = session;
this.persistentClass = persistentClass;
}
...
public void delete(T t){
session.delete(t);
}
BaseFacade:
public interface BaseFacade<T> extends Serializable {
...
public abstract void remove(T t);
PacienteFacade
public interface PacienteFacade extends BaseFacade<Paciente> {
public void remove(Paciente paciente);
PacienteFacadeImpl
public class PacienteFacadeImpl implements PacienteFacade {
private static final long serialVersionUID = 1818242808424001885L;
private PacienteDao pacienteDao;
private SessionFactory sf;
private Session session;
private Transaction tx;
public void remove(Paciente p) {
sf = new AnnotationConfiguration().configure().buildSessionFactory();
session = sf.openSession();
tx = session.beginTransaction();
pacienteDao = new PacienteDao(session, Paciente.class);
pacienteDao.delete(p);
tx.commit();
session.close();
}
PacienteController
public class PacienteController implements Serializable {
private static final long serialVersionUID = -333995781063775201L;
private Paciente paciente = new Paciente();
private List<Paciente> lista = new ArrayList<Paciente>();
private Integer id;
public String removePaciente(){
PacienteFacade pacienteService = new PacienteFacadeImpl();
pacienteService.remove(this.paciente);
paciente = new Paciente();
return "pacienteExcluido";
}
E a pagina listarPaciente.jsf
<html xmlns = "http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<ui:composition template="/template/template.xhtml">
<ui:define name="topo">
<ui:include src="/menu.xhtml">
</ui:include>
</ui:define>
<ui:define name="corpo">
<h:form>
<h:panelGrid columns="3">
<h:outputText value="Nome: " />
<h:inputText id="Nome" value="#{paciente.nomePesquisa}" />
</h:panelGrid>
<h:commandButton value="Pesquisar" action="#{paciente.pesquisaPacientes}" />
</h:form>
<h:form>
<h:dataTable value ="#{paciente.pacientes}" var = "pc"
border="0" headerClass="cabecalho" rowClasses="linha1,linha2,linha3,linha4">
<h:column>
<f:facet name="header">
<h:outputText value = "Id"/>
</f:facet>
<h:outputText value="#{pc.id_paciente}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value = "Nome"/>
</f:facet>
<h:outputText value="#{pc.nome_paci}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value = "CPF"/>
</f:facet>
<h:outputText value="#{pc.cpf_paci}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value = "DataNascimento Paciente"/>
</f:facet>
<h:outputText value="#{pc.data_nas}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Excluir" />
</f:facet>
<h:commandLink value="Excluir" action="#{paciente.removePaciente}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Editar" />
</f:facet>
</h:column>
</h:dataTable>
</h:form>
</ui:define>
</ui:composition>
</html>
Não estou conseguindo…