【问题标题】:Primefaces <p:inplace> text fields populated with Strings from ArrayList, not updating in table with Ajax savePrimefaces <p:inplace> 使用 ArrayList 中的字符串填充的文本字段,不使用 Ajax 保存在表中更新
【发布时间】:2015-07-20 18:21:40
【问题描述】:

我有一个包含 &lt;p:inplace&gt;&lt;p:inputText&gt; 的数据表,我用 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" 只是字符串之一。

【问题讨论】:

  • 列表 #{editServiceBean.ops} 返回什么?操作对象或字符串列表或?
  • @Emil Kaminski 它返回一个字符串列表

标签: jsf primefaces


【解决方案1】:

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

创建一个包含 String 作为项目列表的包装类。

【讨论】:

    猜你喜欢
    • 2021-09-19
    • 1970-01-01
    • 1970-01-01
    • 2011-10-02
    • 2018-04-19
    • 2015-05-10
    • 1970-01-01
    • 2018-05-15
    • 1970-01-01
    相关资源
    最近更新 更多