0
我需要在這種情況下使用兩種不同的驗證。如果未選擇該值並提交表單,則需要顯示第一個。將ajax驗證與表單驗證相結合
第二個應該立即驗證,當用戶選擇「是」的答案。 到目前爲止,ajax請求工作正常,但沒有選擇任何值時,我只會得到一個警告: (有一些未處理的FacesMessages,這意味着並不是每個FacesMessage都有機會被渲染,這些未處理的FacesMessages是:...)
我認爲從同一個p:消息中的p:selectOneRadio-Tag中捕獲不同的消息存在問題。任何人都可以驗證我的想法還有哪些其他可能的解決方案結合了這兩種不同類型的驗證? 下面的代碼:
<h:form id="formHealtData">
<p:panelGrid columns="1"
layout="grid"
cellpadding="5">
<h:outputLabel for="hQuestion1"
value="FirstQuestion" />
<p:selectOneRadio id="hQuestion1"
value="#{applicationData.hQuestion1}"
required="true"
requiredMessage="Please answer the question!">
<f:selectItem itemValue="#{true}" itemLabel="Yes" />
<f:selectItem itemValue="#{false}" itemLabel="No" />
<f:validator for="hQuestion1"
validatorId="trueQuestionValidator" />
<p:ajax event="change" update="messQ1" />
</p:selectOneRadio>
<p:message id="messQ1"
for="hQuestion1" />
</p:panelGrid>
<p:commandButton id="next"
value="Next"
action="paymentdata">
</p:commandButton>
</h:form>