我试图在primefaces上实现排序功能dataTable.Sorting正在运行。但是当我删除时,更新dataTable项,dataTable没有任何影响(没有任何变化)。那就是dataTable没有被清除或刷新。但是在数据库删除中,更新没有发生任何问题。当我退出并重新登录时,新列表(dataTable)没问题。
employeeView.jsf:
<p:dataTable id="employees" value="#{employeeList.employees}"
var="employee" emptyMessage="No Employees found" rows="10"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15" rowIndexVar="rowIndex">
<p:column sortBy="#{employee.firstName}">
<f:facet name="header">
<h:outputText value="First Name" />
</f:facet>
<h:outputText value="#{employee.firstName}">
</h:outputText>
</p:column>
<p:column sortBy="#{employee.lastName}">
<f:facet name="header">
<h:outputText value="Last Name" />
</f:facet>
<h:outputText value="#{employee.lastName}" />
</p:column>
</p:dataTable>
EmployeeList.java:
@Component("employeeList")
@SessionScoped
@Repository
public class EmployeeList implements Serializable {
private static final long serialVersionUID = -2417394435764260084L;
public static HibernateTemplate hibernateTemplate;
private List<Employee> employees = new ArrayList<Employee>();
@Autowired
public void setSessionFactory(SessionFactory sessionFactory)
{
this.hibernateTemplate = new HibernateTemplate(sessionFactory);
}
public List<Employee> getEmployees() {
if(employees.isEmpty()){
employees.addAll(empList());
}
return employees;
}
@SuppressWarnings("unchecked")
public List<Employee> empList() {
try
{
List <Employee> result = hibernateTemplate.find("from Employee");
return result;
}
finally {
//close the session and user-supplied JDBC connection
}
}
}
我曾尝试使用@RequestScope,@ ViewScope等但没有效果。我哪里出错了?
使用JSF2和Google Cloud SQL的Primefaces-3.0.M3