我有一个p:selectOneMenu,我想验证selectedItem。我的代码是:
<tooltip />
<p:selectOneMenu id="cardTypes" style="width: 150px" value="#{viewTrasactionsBean.transactionAhorroFiltroWrapper.tipoTarjeta}" required="true" requiredMessage="Debe seleccionar un Tipo de Tarjeta válido">
<f:selectItem itemLabel="Seleccionar..." itemValue="#{null}"/>
<f:selectItem itemLabel="Todas" itemValue="ALL" />
<f:selectItems value="#{viewTrasactionsBean.cardTypes}" var="types" itemLabel="#{types.descripcion}" itemValue="#{types.codigo}"/>
<f:validator validatorId="cardTypesValidator"/>
</p:selectOneMenu>
<p:message for="cardTypes" display="tooltip" />
验证器抛出ValidatorException,但由于某种原因,工具提示(或消息)从未显示过。
我使用的是Primefaces 4.0
验证码:
@FacesValidator("cardTypesValidator")
public class CardTypesValidator implements Validator {
@Override
public void validate(FacesContext fc, UIComponent c, Object o) throws ValidatorException {
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "ESTE ES EL ERROR"));
}
}