2014-07-23 54 views
0

從Mojarra 2.1.13將一個大項目升級到2.1.28時,我們注意到h:commandButton中的所有action和actionEvent方法在每個頁面被調用執行表單的ajax請求。我們能夠通過type =「button」將問題縮小到commandButton。這些在2.1.13中工作正常,但升級後,點擊一個按鈕會觸發所有其他操作。Mojarra every commandButton action and actionEvent is called on ajax request

下面是用於重建問題的代碼:

<h:form id="form"> 

     <h:commandButton type="button" value="Action1" action="#{page1.action1}"> 
      <f:ajax execute="@form" render="@form" /> 
     </h:commandButton>  
     <h:commandButton type="button" value="Action2" action="#{page1.action2}"> 
      <f:ajax execute="@form" render="@form" /> 
     </h:commandButton> 
     <h:commandButton type="button" value="Action3" action="#{page1.action3}"> 
      <f:ajax execute="@form" render="@form" /> 
     </h:commandButton> 

</h:form> 

注意,當按鈕類型未設置或設置爲「提交不會發生這種情況看起來這種行爲與鑽嘴魚科介紹。2.1.14

有沒有人見過這個是否有去除這些按鈕類型=「按鈕」任何方面的考慮,特別是關於請求生命週期? -

+1

儘管這種行爲可能被認爲是框架中的一個錯誤,但'type =「按鈕並不是用來調用服務器端的操作方法。它通常用於調用一些客戶端相關的代碼,通常是javascript。所以在這種情況下,這個屬性是不必要的,並被濫用。 –

+0

有道理。所以這個bug在2.1.14之前,它允許這個工作正常。框架應該拋出一個錯誤,以防止這樣的代碼。 –

回答