我正在使用带有行编辑器的数据表,我的代码或多或少与 primefaces 网站上展示示例中的代码相同,但由于某种原因,这些值没有更新。
此外,当我单击铅笔进行编辑时,当前值未显示在编辑单元格中。
这是我的代码:
xhtml:
<h:form id="updateform">
<p:dataTable id="updatetable" value="#{EditingBean.row}" var="column"
editable="true"
style="width: 780px; overflow-x: auto; white-space: normal;">
<f:facet name="header">TEST</f:facet>
<p:column rendered="#{column.display}" style="white-space: normal;">
<h:outputText value="#{column.alias}" />
</p:column>
<p:column rendered="#{column.display}" style="white-space: normal;">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{column.value}" />
</f:facet>
<f:facet name="input">
<p:inputText value="{#column.value}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column rendered="#{column.display}" style="white-space: normal;">
<p:rowEditor rendered="#{column.modify}" />
</p:column>
</p:dataTable>
</h:form>
编辑豆:
@ManagedBean(name = "EditingBean")
@ViewScoped
public class EditingBean implements Serializable {
private static final long serialVersionUID = -772702647887310138L;
private List<Result> row;
public List<Result> getRow() {
return row;
}
public void setRow(List<Result> row) {
this.row = row;
}
}
结果:
public class Result implements Serializable {
private static final long serialVersionUID = 1L;
private String alias;
private String name;
private String value;
private String modify;
private String display;
// getters + setters