[英]How to validate a List<Object> in a Primefaces dataTable - JSF
I have a dataTable for Phone something like : 我有一个用于电话的dataTable之类的东西:
<p:dataTable value="#{billingInfoBean.billingProfile.payer.phones}" var="phone" id="payerPhoneTable">
<p:column>
<f:facet name="header">
<h:outputText value="Type" />
</f:facet>
<p:selectOneMenu value="#{phone.type}">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{backOfficeLookupClient.allPhoneTypes}" />
</p:selectOneMenu>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Area Code" />
</f:facet>
<h:inputText value="#{phone.areaCode}" size="3" maxlength="3" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Exchange" />
</f:facet>
<h:inputText value="#{phone.exchange}" size="3" maxlength="3" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Local" />
</f:facet>
<h:inputText value="#{phone.local}" size="4" maxlength="4" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Extension" />
</f:facet>
<h:inputText value="#{phone.extension}" size="5" maxlength="5" />
</p:column>
</p:dataTable>
I am trying to use custom validation using the object Phone. 我正在尝试使用对象Phone使用自定义验证。 I need to call a Phone Validation service which takes these column values as inputs.
我需要调用电话验证服务,该服务将这些列值作为输入。 Can I make use of
<f:validator>
here in this case?, If yes, how ? 在这种情况下,我可以在这里使用
<f:validator>
吗?
You could attach to the dataTable
a validator listener 您可以将验证器侦听器附加到
dataTable
<f:event type="postValidate" listener="#{bean.customValidation}"/>
And validate the phone object in your bean 并验证bean中的电话对象
public void customValidation(ComponentSystemEvent event) {
...
}
Then iterate through all dataTable childrens and validate each one. 然后遍历所有dataTable子项并验证每个子项。
This omnifaces tag solved my problem : 这个omnifaces标签解决了我的问题:
http://showcase.omnifaces.org/validators/validateMultiple http://showcase.omnifaces.org/validators/validateMultiple
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.