When saving an entity, how one can change the position of notifications showing the validation errors?
Hello!
In this case, you should show your own notification.
Disable standard notification:
@Subscribe
public void onInit(final InitEvent event) {
setShowValidationErrors(false);
}
And set fail handler to saveAction
:
@Autowired
private Notifications notifications;
@Autowired
private Messages messages;
@Install(to = "saveAction", subject = "failHandler")
private void saveActionFailHandler() {
ViewValidation viewValidation = getApplicationContext().getBean(ViewValidation.class);
ValidationErrors validationErrors = viewValidation.validateUiComponents(getContent());
String message = ViewValidation.getValidationErrorsMessage(validationErrors);
notifications.create(messages.getMessage("validationFail.title"), message)
.withPosition(Notification.Position.MIDDLE)
.show();
}