2011-06-15 53 views
0

是否可以在顯示驗證失敗的消息後禁用輸入域的重新渲染?在顯示驗證消息後禁用輸入域的重新渲染

這是我的一塊視圖:

<h:outputLabel for="captcha" value="#{ui.pleaseEnterTextInTheImage}" rendered="#{sessionBean.showCaptcha}"/> 
<h:panelGroup rendered="#{sessionBean.showCaptcha}"> 
    <h:inputText id="captcha" styleClass="captcha" validator="#{validationBean.captchaValidator}" /> 
    <h:outputText value=" "/><h:message for="captcha" styleClass="captchaMsg"/> 
</h:panelGroup> 

回答

1

是的,待驗證的輸入組件綁定到視圖和在呈現狀態檢查UIInput#isValid()

<h:inputText binding="#{captcha}" required="true" /> 
... 
<h:inputText rendered="#{captcha.valid}" /> 

當第一個驗證錯誤發生時,第二個會在表單提交時消失。

相關問題