我有一个使用primefaces和JSF的简单表单。点击保存后,它会显示另一个jsf页面,我有一个primefaces数据表。它应该在数据表中显示新创建的记录,而不是这种情况。为了查看新记录,我必须返回到另一个页面,然后重新打开具有数据表的页面。我可以看到新的纪录。如何解决这个问题,使点击保存我可以看到新的记录?dataTable在保存后不显示新添加的项目
<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之前/之后保存? – Fritz
请按照最佳实践 - 提供相关库的版本,在这种情况下例如JSF和PrimeFaces。 –
primefaces 5.0和jsf 2.0 – asma