How to finish validation with sending all form data in Vaadin 8? Unfortunetly I dont understand binder concept I wrote a field validation but what now? It works. My user see when I demand that he fill out a field but is there any easy way to validate my all form? How can I “tell” to my save button that my form is valid?
In my editor Im defining a validator
[code]
@SpringComponent
@PrototypeScope
public class VaadinStringEditor extends TextField implements HasValueComponent {
private Binder<String> binder;
@PostConstruct
public void init() {
setWidth("100%");
binder = new Binder<>();
}
@Override
public void initDefaults() {
setValue("");
binder.validate();
}
@Override
public void setConfiguration(EditorConfiguration editorConfiguration) {
Validator<String> validator = ((TextFieldConfiguration) editorConfiguration).getValidator();
if (validator != null) {
binder.forField(this).withValidator(validator).asRequired("Mandatory").bind(s -> getValue(),
(b, v) -> setValue(v));
}
}
}
[/code]and in my quesions class
question.setEditorConfiguration(new TextFieldConfiguration(textRequiredValidator()));
private Validator<String> textRequiredValidator() {
return Validator.from(v -> v != null && StringUtils.trimAllWhitespace((String) v).length() != 0,
"It cannot be empty!!!");