Do you know how to let the notifications stay for whole duration when switching pages ? I would like to notify user with notification and let that notification persist on switching page by server.
Example:
if (validateInput(oldPassword, newPassword1, newPassword2)) {
Notifications.showSuccessNotification("Heslo uspešne zmenené");
String email = SecurityUtils.getLoggedInUser();
User user = userService.getUserByEmail(email);
user.setPassword(newPassword1);
userService.changePassword(user);
UI.getCurrent().getPage().setLocation(MainGuestView.URL);
}
Internal implementation of Notification in my project looks like this and nevertheless it still disappears sooner than 3000ms.
public static void showSuccessNotification(String text) {
showNotification(text, NotificationVariant.LUMO_SUCCESS);
}
/**
* Method displays a notification inside user's browser window
*
* @param text The text of the notification
* @param variant The variant of the notification
*/
private static void showNotification(String text, NotificationVariant variant) {
Notification notification = new Notification(text, 3000);
notification.addThemeVariants(variant);
notification.setPosition(Notification.Position.TOP_CENTER);
notification.open();
}