我只有<p:dataTable/>
。當我在另一個頁面中向該表格添加新行時,表格不會刷新。 RmaBean是managedBean範圍的會話。有任何想法嗎?如何在每次下載頁面時更新Primefaces數據表?
<h:form id="mainMenuForm">
<p:dataTable id="dataTable"
var="case"
value="#{RmaBean.rmaModel}"
widgetVar="rmaTable"
editable="true"
rows="10" paginator="TRUE" emptyMessage="No items found with given criteria.">
...
<p:column></p:column>
<p:column></p:column>
<p:column><p:commandButton action="#{MainController.talletaUusiRma}" value="#{bundle.newRma_tallenna}" immediate="true" ajax="false" style="width: 220px;"/></p:column>
</p:row>
當我添加一個新的對象到該表,我剛更新rmaModel
每一次,我甚至檢查清單比以前更長之一,有那個新的對象。 dataTable仍顯示沒有新對象的舊數據,爲什麼?
--------創建新RMA -------------
public String prepareNewRma() {
current = new Rma();
current.setUser("");
return "newRma";
}
--------獲取數據TO THE NEW RMA WITH序列號------
public String haeTiedotSarjanrolla() {
log.info("sarjanro=" + current.getSarjanro());
System.out.println("---------------->sarjanro=" + current.getSarjanro());
Sarjanumerot s = helper.getSerialInfo(current.getSarjanro());
if (s != null) {
current.setAn8(s.getAn8());
current.setDsc1(s.getDsc1());
current.setDsc2(s.getDsc2());
current.setSarjanro(s.getId().getLotn());
current.setTuotenro(s.getId().getLitm());
}
return "newRma";
}
--------保存新的RMA ---------------
public String talletaUusiRma() {
current.setCreated(new Timestamp(System.currentTimeMillis()));
helper.tallennaRma(current);
rmaNumbers = null;
RmaBean papu = (RmaBean) JsfUtil.findBean("rmapapu");
papu.updateTable();
return "mainMenu";
}
HELPER:
public void tallennaRma(Rma current) {
try {
Session session = HibernateUtil.getAsekorjausSessionFactory().getCurrentSession();
session.beginTransaction();
session.saveOrUpdate(current);
session.getTransaction().commit();
} catch (Exception e) {
log.debug(e.getMessage());
JsfUtil.addErrorMessage(ResourceBundle.getBundle("resources/Bundle").getString("editRma_err_updateError"));
}
---------修正模型和表中RmaBean -----------
public void updateTable(){
System.out.println("updateTableupdateTableupdateTable");
rmaModel.setWrappedData(rmaModel.getUpdatedList());
System.out.println("1111111..........");
List<Rma> rmat = rmaModel.getUpdatedList();
System.out.println("22222222.......");
Iterator iter = rmat.iterator();
System.out.println("------------------------>PITUUS: " +rmat.size());
while (iter.hasNext()) {
Rma t = (Rma) iter.next();
System.out.println("t.getRma()NUMERO------->" +t.getRma());
}
RmaDataModel newRMAModel = new RmaDataModel(rmat);
rmaModel = newRMAModel;
}
薩米
您能夠利用它增加了一個新元素到列表中的方法延長你的問題?請修正上面的代碼片段,發佈方法的整個代碼或張貼方法簽名並標記缺少的代碼片段。 –
現在可以嗎?我昨天很累,我試圖變得快速:) – Sami