Primefaces <p:inplace> 文本字段填充了来自 ArrayList 的字符串,未在 table 中更新 Ajax 保存

Primefaces <p:inplace> text fields populated with Strings from ArrayList, not updating in table with Ajax save

我有一个包含 <p:inplace><p:inputText> 的数据表,我用 ArrayList 中的字符串进行填充。更新值后,我无法保存它,它只是恢复到原来的值。

这是 xhtml:

<p:panel styleClass="center" id="opPanel">
    <h:outputText value="Add Operations" />
    <p:dataTable id="ops" value="#{editServiceBean.ops}" var="op">
        <p:column headerText="Operations">
            <p:inplace editor="true" emptyLabel="">
                 <p:inputText id="operations" value="#{op}" />
                 <p:ajax event="save" update="dataForm:opPanel, dataForm:edit, dataForm:ops, ops:operations" />
            </p:inplace>
        </p:column>
    </p:dataTable>
</p:panel>

"ops" 只是一个 ArrayList 字符串,所以 var "op" 只是其中一个字符串。

您不能在此示例中使用字符串列表。字符串是不可变的,这导致 inputText 无法在您的项目上设置值。

创建一个包含字符串的包装器 class 作为您的项目列表。