2014-09-30 141 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