I want to modify the behaviour by default of displaying error validation in a form .
I want to display the error messaage in a label above each field.
If i bind field by field
binder.forField(field1)
.withValidationStatusHandler(status -> {
field1Label.setValue(status.getMessage().orElse("")
})
.bind(Bean::getField1, Bean::setField1);
And so on with others fields.
But if a bind with instanceFields method what can i do. I found it in the doc, api and other threads of the forum the method setValidationStatusHandler
binder.bindInstanceFields(this);
binder.setValidationStatusHandler(status -> {
List<BindingValidationStatus<?>> fieldValidationErrors = status.getFieldValidationErrors();
for(BindingValidationStatus<?> fieldValidationError : fieldValidationErrors) {
String message = fieldValidationError.getMessage().get();
HasValue<?> field = fieldValidationError.getField();
... /?
}
});
I have the field and the message but how i put the value in the corresponding label?
If i do it field by field i’would use withStatusLabel
In the doc i read about setStatusLabel to set a Label to show validation error messages. But again you only can use it field by field
binder.forfield(field1)
.setStatusLabel(field1Label)
.bind(Bean::getField1, Bean::setField1);