You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation of save() method in Grid's inline Editor is as follows (EditorImpl.java):
@Override
public boolean save() {
if (isOpen() && isBuffered()) {
getBinder().validate();
if (getBinder().writeBeanIfValid(edited)) {
fireSaveEvent(new EditorSaveEvent<>(this, edited));
close();
return true;
}
}
return false;
}
The getBinder().validate() call is there apparently for the possible case that Grid has fetched data with invalid properties. This is valid scenario in some applications. The side effect of this is that validations are run twice as both validate() and writeBeanIfValid(..) runs the validations. This is a problem if the validators are heavy, e.g. having backend calls.
I would recommend to remove the getBinder().validate() and instead add documentation for developer to call it explicitly in the application code if needed by business logic of the application. In many cases it would be better to call it already when editor opens and not at save stage.
Alternatively there could be additional API to configure whether additional pre-validation is being performed or not and let it be default in order to avoid breaking change.
Expected outcome
Validators not being run twice.
Minimal reproducible example
Trivial.
Steps to reproduce
Trivial.
Environment
Vaadin version(s): latest 14, 23, 24 versions.
Browsers
No response
The text was updated successfully, but these errors were encountered:
Description
The current implementation of save() method in Grid's inline Editor is as follows (EditorImpl.java):
The
getBinder().validate()
call is there apparently for the possible case that Grid has fetched data with invalid properties. This is valid scenario in some applications. The side effect of this is that validations are run twice as bothvalidate()
andwriteBeanIfValid(..)
runs the validations. This is a problem if the validators are heavy, e.g. having backend calls.I would recommend to remove the
getBinder().validate()
and instead add documentation for developer to call it explicitly in the application code if needed by business logic of the application. In many cases it would be better to call it already when editor opens and not at save stage.Alternatively there could be additional API to configure whether additional pre-validation is being performed or not and let it be default in order to avoid breaking change.
Expected outcome
Validators not being run twice.
Minimal reproducible example
Trivial.
Steps to reproduce
Trivial.
Environment
Vaadin version(s): latest 14, 23, 24 versions.
Browsers
No response
The text was updated successfully, but these errors were encountered: