我有一個使用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