We have bumped into unexpected behavior from the BindingValidationStatus.
The following fragment is in the constructor of a Composite<Dialog>:
binder.forField(tagComboBox)
.withValidator((tags, context) -> {
System.out.println("Binder has changes: " + binder.hasChanges());
if (isValid(tags) && binder.hasChanges()) {
System.out.println("Tags are valid");
return ValidationResult.ok();
} else {
System.out.println("Tags are NOT valid");
var error = ValidationResult.error("Not yet supported");
System.out.println(error);
return error;
}
})
.withValidationStatusHandler(
status -> {
status.getValidationResults().stream().forEach(System.out::println);
System.out.println(status.getValidationResults().isEmpty());
System.out.println(status.isError());
// System.out.println("Validation status isOk: " + isOk);
// applyButton.setEnabled(isOk);
})
.bind(x -> x, (x, y) -> {
selectedTags.clear();
selectedTags.addAll(y);
});
While debugging with the print statements, we noticed that when an error is expected in the list of ValidationResults. There is nothing:
true
false
Binder has changes: false
Tags are NOT valid
ValidationResult{error='Not yet supported', errorLevel=ERROR}
true
false
While we were expecting:
true
true
Binder has changes: false
Tags are NOT valid
ValidationResult{error='Not yet supported', errorLevel=ERROR}
{error}
false
true
This is playing with our validation and how our apply button behaves. As it gets an OK instead of an error.
Is there anyone who recognizes this issue and/or knows a good solution to this?