ウィザードに埋め込まれたピックリストがあり、ターゲットで何かが選択された場合にのみ次のステップに進みます。それは機能しますが、問題はレンダリング時に検証が起動することです。ユーザーが最初に目にするのは、「次へ」ボタンを押す前であってもエラーメッセージです。これをオフにする方法はありますか?
ここにxhtmlがあります:
<p:pickList id="pickList" value="#{someBean.Rules}"
var="rule"
itemLabel="#{rule.name}"
itemValue="#{rule}"
converter="accountingObjectConverter"
responsive="true"
showSourceFilter="true" showTargetFilter="true"
filterMatchMode="contains"
style="width: 100%"
validator="myValidator"
>
<f:facet name="sourceCaption">Select</f:facet>
<f:facet name="targetCaption">Selected</f:facet>
<p:column>
<h:outputText value="#{rule.name}"/>
</p:column>
</p:pickList>
これが私のバリデータです:
@FacesValidator("myValidator")
public class MyValidator implements Validator {
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
checkForEmptyFields(context, component, (DualListModel) value);
}
private void checkForEmptyFields(FacesContext context, UIComponent component, DualListModel value) {
if ( value.getTarget().size() == 0) {
((UIInput) component).setValid(false);
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error: must select at least one item", ""));
}
}
}
お時間をいただきありがとうございます。
編集:ここにウィザードがあります:
<h:form id="mainForm">
<p:wizard id="ruleWizard" widgetVar="ruleWiz"
flowListener="#{aBeanL.flowListener}"
nextLabel="next"
backLabel="back">
<p:tab id="queryTab" title="rules">
<ui:include src="theXhtmlAbove.xhtml"/>
</p:tab>
*some tabs*
</p:wizard>
</h:form>