ColorPicker 验证和要求不工作

ColorPicker validation and required not working

起初我只尝试使用 'required' 属性,但由于它似乎从未被检查过,所以我添加了一个非常简单的验证器来检查 'color' 属性 的长度...但似乎没有任何效果。在相同的表单中,我还有其他 inputText 所需的组件,当我按下 commandButton 时,这些组件会被正确检查。

我有以下代码:

<p:colorPicker id="color" value="#{backBean.color}" required="true"  requiredMessage="Required!" validator="ColorValidator" validatorMessage="Required!"/>

<p:commandButton id="createOrUpdateButton"
                 actionListener="{backBean.createOrUpdate}"
                 process="@form"
                 update="@all"
                 value="Save"
                 style="width: 95%;" />

验证者:

@FacesValidator("ColorValidator")
public class ColorValidator implements Validator{

public ColorValidator(){

}
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    if (value==null || value.toString().trim().isEmpty()) {
      FacesMessage msg = new FacesMessage("Color validation failed.","Please select a color.");
      msg.setSeverity(FacesMessage.SEVERITY_ERROR);
      throw new ValidatorException(msg);
    }
  }

}

答案是:根本不支持!

Issue #5887 and issue #5892 解决此问题并提供应包含在 PrimeFaces 9.0 版中的修复程序。