2014-09-30 155 views
0

我需要跳過h:form內部的輸入組件,因爲它僅保留在那裏僅用於純粹的表示需要&不會向任何bean字段提交值。提交表單時如何禁用其提交以及其他表單輸入?防止p:selectOneListbox被提交到h:表單

 <h:form> 
      <!--other input components--> 

      <p:selectOneListbox id="deptsSel"> 
       <f:selectItems value="#{listRetriever.list}" 
           var="dept" itemLabel="#{namesDirectory.getName(dept)}" itemValue="#{dept}" /> 
      </p:selectOneListbox> 

      <!--other input components--> 
     </h:form> 

我省略了value屬性爲p:selectOneListbox,但在提交它仍然給驗證錯誤的形式:「」

+1

看起來像http://stackoverflow.com/questions/12614882/how-to-exclude-child-component-in-ajax-update-of-a-parent-component的副本。 – 2014-09-30 13:51:39

+0

你爲什麼這麼擔心?如果你沒有在你的bean中使用這個組件,那就把它放在一邊吧 – Pellizon 2014-09-30 16:48:46

+0

你用什麼來提交表單,一個命令按鈕? – Pellizon 2014-09-30 16:52:03

回答

1

期間postback禁用它,只要它不是rendering the response

<p:selectOneListbox ... disabled="#{facesContext.postback and facesContext.currentPhaseId.ordinal ne 6}"> 

作爲防止被黑請求JSF保障的一部分,UIInput組件的disabled屬性也即請求處理過程中,通過在JSF生命週期所有階段,包括驗證階段服從。


無關的具體問題,你可能會感興趣的頭部知道什麼時候和到底爲什麼會出現特定的驗證錯誤,給Validation Error: Value is not valid。這就是一個強烈的暗示,即使你從未滿足於更新模型,它的模型仍然被打破,但它仍然會在鏈條的其他地方產生其影響。

+0

謝謝,但是當我嘗試ajax更新它時,我禁用了輸入組件。我只需要在表單提交時禁用它,而不是通過ajax更新。 – 2014-09-30 19:27:05

+0

查看更新的答案。 – BalusC 2014-09-30 20:01:51

+0

非常感謝你!有用 :) – 2014-09-30 21:29:36