Combobox vaadin 8组合框:RemoveAllValidator

Combobox vaadin 8组合框:RemoveAllValidator,combobox,vaadin7,vaadin8,Combobox,Vaadin7,Vaadin8,在vaadin 7com.vaadin.ui.ComboBox中有removeAllValidators()。 vaadin 8中是否有removeAllValidators()的替代品?在vaadin 8中,以及在随后的vaadin 10,14中,版本验证程序API不再直接位于字段中。取而代之的是,Vaadin8引入了一个名为的新概念,它使用验证器-转换器链处理数据绑定 使用Binder,您可以使用builder模式形成验证器-转换器链,请参见下面的示例 binder.forField(yea

在vaadin 7
com.vaadin.ui.ComboBox
中有
removeAllValidators()

vaadin 8中是否有
removeAllValidators()
的替代品?

在vaadin 8中,以及在随后的vaadin 10,14中,版本验证程序API不再直接位于字段中。取而代之的是,Vaadin8引入了一个名为的新概念,它使用验证器-转换器链处理数据绑定

使用Binder,您可以使用builder模式形成验证器-转换器链,请参见下面的示例

binder.forField(yearOfBirthField)
  // Validator will be run with the String value of the field
  .withValidator(text -> text.length() == 4,
    "Doesn't look like a year")
  // Converter will only be run for strings with 4 characters
  .withConverter(
    new StringToIntegerConverter("Must enter a number"))
  // Validator will be run with the converted value
  .withValidator(year -> year >= 1900 && year < 2000,
    "Person must be born in the 20th century")
  .bind(Person::getYearOfBirth, Person::setYearOfBirth);
活页夹是用Bean键入的,您可以在表单中使用Bean。若您只有一个字段,那个么活页夹可能是一个多余的功能,您可以使用附加组件

binder.removeBinding(yearOfBirthField);