JSF inputText只读取值=" true"

时间:2017-10-19 12:46:19

标签: jsf primefaces

在设置控制器中的属性并使用ajax更新时,有人可以解释为什么h:inputText必须有required="true"吗?

不起作用:

<h:inputText id="textFieldId" value="#{model.itemValue}">

使用:

<h:inputText id="textFieldId" value="#{model.itemValue}" required="true">

动作:

<p:commandLink value="edit">
   <p:ajax event="click" listener="#{controller.edit(item)}" process="@this" update="@form"/>
</p:commandLink>

背后的想法是我想按项目按钮并能够编辑所以我需要将此项目传播到inputText。

我没有看到任何理由要求设置为true。

由于

1 个答案:

答案 0 :(得分:1)

PrimeFaces p:commandLink默认已启用ajax,因此无需在其中嵌套p:ajax标记。

<p:commandLink value="edit" actionListener="#{controller.edit(item)}"
     process="@this" update="@form"/>

但请记住,如果添加process="@this",则不会在服务器上处理输入,只会处理commandLink。如果在这种情况下正确传递'item'字段,我不清楚。