【问题标题】:Cannot pass component to process无法将组件传递给进程
【发布时间】:2014-09-04 07:52:31
【问题描述】:

我正在尝试在 JSF 中处理输入并执行操作,但该操作甚至没有执行。 这是我尝试使用样式类引用组件的代码:

<h:panelGroup layout="block">
    <p:inputText id="txtClientCIN" widgetVar="ClientCIN" value="#{client.clientCIN}" required="true" styleClass="textcin"/>
    <p:commandButton id="btnSearchClient" icon="ui-icon-search" action="#{client.checkCIN}" process="@(.textcin)" update="@form" style="margin-left: 10px;"/>
</h:panelGroup> 

我尝试通过设置 process="txtClientCIN" 来使用 id 引用它

但也没有用。

当我将进程更改为 @form 时,checkCIN() 方法执行得很好。

【问题讨论】:

  • 尝试一下 process="@this txtClientCIN"
  • :o 成功了……谢谢!但为什么?只有id还不够?

标签: jsf primefaces


【解决方案1】:

据我了解:

有一个像这样的标准命令按钮:

<p:commandButton actionListener=“#{bean.method}”/>

将处理@form,调用 bean.method() 并且不更新任何内容。

改为这个

<p:commandButton actionListener=“#{bean.method}” 
                 process=“someComponentId” 
                 update=“otherComponentId”/>

将处理“someComponentId”并更新“otherComponentId”。但是现在命令按钮本身不会被处理,就像在第一个示例中那样。意思是 bean.method() 不会被调用。

所以我们需要

<p:commandButton actionListener=“#{bean.method}” 
                 process=“@this someComponentId” 
                 update=“otherComponentId”/>

或者要么完全省略 process 属性,要么将其设置为“@form”(这是多余的)。

进一步阅读答案here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-21
    • 1970-01-01
    • 1970-01-01
    • 2019-11-11
    • 2016-01-10
    • 2018-04-08
    相关资源
    最近更新 更多