2014-07-14 89 views
0

我试图处理一个输入并在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来引用,但也did'nt工作。

当我改变进程@formcheckCIN()方法得到执行很好。

+1

试试process =“@ this txtClientCIN” –

+0

:o它的工作......谢谢!但为什么?该ID只是不够? –

回答

2

据我了解:

拥有一个标准的commandButton这样的:

<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”/> 

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

更多阅读答案here