[英]Primefaces datatable cell editing doesn't update
I have a primefaces datatable with cell editing which is toggled on a boolean variable in the view. 我有一个带有单元格编辑的primefaces数据表,该表在视图中的布尔变量上切换。
I have three issues: 我有三个问题:
Here is the code: 这是代码:
<p:dataTable value="#{view.LineItems}" var="lineItem" rowKey="#{lineItem.lineItemId}"
resizableColumns="false" editable="#{view.editable}" editMode="cell"
editingRow="#{view.editable}" id="requestLineItemsTable">
<p:ajax event="cellEdit" listener="#{view.cellEdited}" immediate="true" update="@this" />
<p:column styleClass="centerColumnData" headerText="Item Name" style="width: 140px;">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{lineItem.title}"/>
</f:facet>
<f:facet name="input">
<h:inputText value="#{lineItem.title}"/>
</f:facet>
</p:cellEditor>
</p:column> ...
and this is the back end (not doing anything with this yet) 这是后端(尚未对此进行任何操作)
public void cellEdited(CellEditEvent event)
{
Object oldValue = event.getOldValue();
}
and here is the save and edit buttons on the same .xhtml page as datatable 这是与数据表相同的.xhtml页面上的保存和编辑按钮
<p:commandLink process="@this"
action="#{view.changeModeToEdit}"
update="@form"
rendered="#{!view.editMode">
<h:graphicImage library="images" name="edit20.png" title="#{__Common.edit}"
style="height: 15px; width: 15px;"/>
</p:commandLink>
<components:linkWithSpinner linkStyle="margin-right: 20px;" loadingImageStyle="margin-right: 20px;"
linkStyleClass="activeButton saveButtonRequestDetails" loadingImageStyleClass="saveButtonRequestDetails"
linkText="#{__CommonButton.save}"
process="@form" update="@form"
actionMethod="#{view.updateRequest()}"/>
view.updateRequest() sets the editable to false. view.updateRequest()将editable设置为false。 I am using Primefaces 4.0
我正在使用Primefaces 4.0
So I figured out a way around these issues. 因此,我想出了解决这些问题的方法。 I was focused on using the built in edit table , but you can just have a normal datatable and the columns can contain input text fields.
我专注于使用内置的编辑表,但是您只能拥有一个普通的数据表,并且这些列可以包含输入文本字段。 Then you don't have to worry about most of the issues in my question above.
然后,您不必担心我上面的问题中的大多数问题。 If you need to switch between edit and non-edit view then I still don't know how to fully fix it except have two datatables in your file with render tags, but then you are duplicating the table one with input text fields and one with output text fields, and that is not the best way to do it.
如果您需要在编辑视图和非编辑视图之间切换,那么我仍然不知道如何完全解决它,除了文件中带有渲染标记的两个数据表外,然后您将复制带有输入文本字段的表和一个复制表。输出文本字段,这不是最好的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.