2014-07-14 88 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