/** * Shows a notification in the current page with given text, duration and * position. * * @param text * the text of the Notification * @param duration * the duration in milliseconds to show the notification * @param position * the position of the notification. Valid enumerate values are * TOP_STRETCH, TOP_START, TOP_CENTER, TOP_END, MIDDLE, * BOTTOM_START, BOTTOM_CENTER, BOTTOM_END, BOTTOM_STRETCH * @return the notification */ public static Notification show(String text, int duration, Position position) { Notification notification = new Notification(text, duration, position); notification.open(); return notification; }
@Override public void validationStatusChange(ValidationStatusEvent<S> statusChangeEvent) { if (statusChangeEvent.isInvalid()) { String error = showAllErrors ? statusChangeEvent.getErrorMessages().stream().collect(Collectors.joining("<br/>")) : statusChangeEvent.getErrorMessage(); if (error == null || error.trim().equals("")) { error = "Validation error"; } if (notification != null) { notification.setText(error); notification.open(); } else { Notification.show(error); } } else { if (notification != null) { notification.close(); } } }
@Override public void onNotificationAdded(Notification notification) { if (!isOpened()) { NotificationViewWithoutWrapper view = new NotificationViewWithoutWrapper(notification, holder); view.setWidth("200px"); com.vaadin.flow.component.notification.Notification notificationView = new com.vaadin.flow.component.notification.Notification(view); notificationView.setPosition(com.vaadin.flow.component.notification.Notification.Position.TOP_END); notificationView.setDuration(2000); notificationView.open(); } }