【发布时间】:2015-09-17 07:30:44
【问题描述】:
我有一个使用 primefaces 和 JSF 的简单表单。单击保存时,它会显示另一个 jsf 页面,其中我有一个 primefaces 数据表。它应该在数据表中显示新创建的记录,但事实并非如此。为了查看新记录,我必须返回另一个页面,然后重新打开我有数据表的页面。我可以看到新记录。如何解决这个问题,以便在点击保存时我可以看到新记录?
<p:dataTable id="dta" value="#{CarComponent.listCars}" var="current" rows="15" paginator="true" paginatorPosition="bottom">
</dataTable>
//method where listCars is populated
public String carLists(){
listCars = new arrayList(carDao.findAll());
return "/jsf/listOfcars.xhtml";
}
//save method - on clicking save it should display the datatable
public String save(Cars car){
carService.save(car);
return "/jsf/listOfcars.xhtml";
}
public String getlistCars() {
return listCars;
}
public void setlistCars(String listCars) {
this.listCars = listCars;
}
【问题讨论】:
-
您确定在保存之前/之后已将汽车添加到 carList 中吗?
-
请 - 作为最佳实践 - 提供相关库的版本,在这种情况下,例如JSF 和 PrimeFaces。
-
primefaces 5.0 和 jsf 2.0