[英]Primefaces Datatable submits wrong data by Celledit
I'm using Primefaces datatable with PF8.我在 PF8 中使用 Primefaces 数据表。
Data is coming from ListDatamodel.数据来自 ListDatamodel。 I want to use Cell editing and implemented it exactly like shown in Primefaces showcase.
我想使用单元格编辑并完全按照 Primefaces 展示中所示的方式实现它。 After 3 or 4 inputs of new values, in the approriate bean the value gets updated, but with the old value.
在 3 或 4 个新值输入后,在适当的 bean 中,值得到更新,但使用旧值。 After a refresh of the page, the behaviour is normal again.
刷新页面后,行为再次正常。
Here is the xhtml:这是 xhtml:
<p:dataTable style= "transform: scale(1); transform-origin: 0 0;" id="costingOverviewData" value="#{costingOverviewBean.model}" var="item"
editable="true" editMode="cell" selectionMode="single" disabledSelection="true"
rowStyleClass="#{(item.konto % 1000) eq 999 ? 'total':null}"
rowKey="#{item.ID}"
>
<p:ajax event="cellEdit" listener="#{costingOverviewBean.onCellEdit}" process="@this" />
<p:column rendered = "#{costingOverviewBean.showVorkalk ne false}" style="min-width: 20px;width:20px; max-width: 20px;">
<h:outputText value="#{item.konto}" />
</p:column>
<p:column style="min-width: 200px;width:200px; max-width: 200px;" >
<h:outputText value="#{item.beschreibung}" />
</p:column>
<p:column rendered = "#{costingOverviewBean.showVorkalk eq true}" width="75" headerText="#{res['COV_VorkalkQuantity']}" style="text-align:right">
<p:cellEditor>
<f:facet name="output">
<p:outputPanel style="#{item.menge_Vorkalk ne null ? 'border-style:solid;border-color:grey;border-width:0.5pt':'border-style:none'}">
<p:outputLabel value="#{item.menge_Vorkalk}">
<f:convertNumber integerOnly="true"></f:convertNumber>
</p:outputLabel>
</p:outputPanel>
</f:facet>
<f:facet name="input">
<p:inputNumber rendered="#{item.menge_Vorkalk ne null ? 'true':'false'}" id="menge_Vorkalk_Input" value="#{item.menge_Vorkalk}" style="width:96%">
</p:inputNumber>
</f:facet>
</p:cellEditor>
... ...
And here the bean:这里是豆子:
public DataModel <KontenrahmenIstkosten> getModel() throws IOException {
if(model == null){
load_Strukturplan();
}
if (model == null){
model = new ListDataModel<KontenrahmenIstkosten>(list);
converter = new NumberConverter();
}
return this.model;
}
...
public void onCellEdit(CellEditEvent event) throws IOException {
System.out.println(event.getNewValue());
System.out.println(event.getRowKey());
init();
//PrimeFaces.current().ajax().update("form:pnlOfferEdit");
}
}
In extreme cases, I got also wrong data in fields which I never touched, and the whole table is messed up.在极端情况下,我在我从未接触过的字段中也得到了错误的数据,整个表格都乱七八糟。
I'm struggling for 3 days now.我现在挣扎了3天。 Any help is appreciated!!
任何帮助表示赞赏!
Edit: during value editing, getmodel() is called several times before calling of onCellEdit().编辑:在值编辑期间,在调用 onCellEdit()之前多次调用 getmodel()。
Is this normal behaviour?这是正常行为吗? From my feeling, I face here a timing issue: Sometimes it is luckily working, sometimes not.
从我的感觉来看,我在这里面临一个时间问题:有时幸运地工作,有时则不然。
Did you try it without the process="@this"?你试过没有 process="@this" 吗? This only submits the values from the component.
这只会提交来自组件的值。
<p:ajax event="cellEdit" listener="#{costingOverviewBean.onCellEdit}"/>
Or you can try adding the id instead of @this或者您可以尝试添加 id 而不是 @this
<p:ajax event="cellEdit" listener="#{costingOverviewBean.onCellEdit}" process="costingOverviewData"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.