jsfデータテーブルの行を削除したいです。私はjsfと休止状態と春を使用しています。しかし、削除アクションは機能しません。Customermanagedbean.java
@ManagedBean(name="CustomerMB")
@RequestScoped
public class Customermanagedbean implements Serializable{
@ManagedProperty(value="#{CustomerBoImpl}")
ICustomerBo customerBoImpl;
List<Customer> CustomerList;
public int customerId;
public String name;
public String address;
public String createdDate;
public ICustomerBo getCustomerBoImpl() {
return customerBoImpl;
}
public void setCustomerBoImpl(ICustomerBo customerBoImpl) {
this.customerBoImpl = customerBoImpl;
}
public List<Customer> getCustomerList() {
CustomerList=new ArrayList<Customer>();
CustomerList.addAll(getCustomerBoImpl().findAllCustomer());
return CustomerList;
}
public void setCustomerList(List<Customer> customerList) {
CustomerList = customerList;
}
public String deleteCustomer(Customer customer){
getCustomerBoImpl().deleteCustomer(customer);
return "";
}// getter and setter method
CustomerBoImpl.java
@Transactional(readOnly = true)
public class CustomerBoImpl implements ICustomerBo{
ICustomerDao customerDaoImpl;
public ICustomerDao getCustomerDaoImpl() {
return customerDaoImpl;
}
public void setCustomerDaoImpl(ICustomerDao customerDaoImpl) {
this.customerDaoImpl = customerDaoImpl;
}
@Transactional(readOnly = false)
@Override
public void deleteCustomer(Customer customer){
getCustomerDaoImpl().deleteCustomer(customer);
}
@Override
public List<Customer> findAllCustomer(){
return getCustomerDaoImpl().findAllCustomer();
}
}
CustomerDaoImpl.java
public class CustomerDaoImpl implements ICustomerDao{
private SessionFactory sessionFactory;
public SessionFactory getSessionFactory() {
return sessionFactory;}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public void deleteCustomer(Customer customer){
sessionFactory.openSession();
getSessionFactory().getCurrentSession().delete(customer);
}
public List<Customer> findAllCustomer(){
sessionFactory.openSession();
List list = getSessionFactory().getCurrentSession
().createQuery("from Customer").list();
return list;
}
}
デフォルト.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
>
<h:head>
<h:outputStylesheet library="css" name="table-style.css" />
</h:head>
<h:body>
<h:dataTable value="#{CustomerMB.getCustomerList()}" var="c"
styleClass="order-table"
headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row"
>
<h:column>
<f:facet name="header">
Customer ID
</f:facet>
#{c.customerId}
</h:column>
<h:column>
<f:facet name="header">
Name
</f:facet>
#{c.name}
</h:column>
<h:column>
<f:facet name="header">
Address
</f:facet>
#{c.address}
</h:column>
<h:column>
<f:facet name="header">
Created Date
</f:facet>
#{c.createdDate}
</h:column>
<h:column>
<f:facet name="header">Action</f:facet>
<h:commandButton value="Delete" action="#{CustomerMB.deleteCustomer(c)}" />
</h:column>
</h:dataTable>
なにが問題ですか?私を助けてください。