/** * Creates a notification message of the specified type, with a bigger * caption and smaller description. * * Care should be taken to to avoid XSS vulnerabilities if html is allowed. * * @param caption * The message caption * @param description * The message description * @param type * The type of message * @param htmlContentAllowed * Whether html in the caption and description should be * displayed as html or as plain text */ public Notification(String caption, String description, Type type, boolean htmlContentAllowed) { registerRpc(rpc); setCaption(caption); setDescription(description); setHtmlContentAllowed(htmlContentAllowed); setType(type); }
@Override public void validationStatusChange(ValidationStatusEvent<?> 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.setCaption(error); notification.show(Page.getCurrent()); } else { Notification.show(error, Type.ERROR_MESSAGE); } } }
@Override public void validationStatusChange(ValidationStatusEvent<?> 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.setCaption(error); notification.show(Page.getCurrent()); } else { Notification.show(error, Type.ERROR_MESSAGE); } } }
/** * Method for displaying notification for the user. * * @param message the message to be displayed * @param description the description of this message */ public void notifyMessage(String message, String description) { final Notification notification = new Notification("Message", Notification.Type.TRAY_NOTIFICATION); notification.setCaption(message); notification.setDescription(description); notification.setDelayMsec(1000); if (getUI() != null) { if (getPage() != null) { notification.show(getUI().getPage()); } } } }
/** * Method for displaying notification for the user. * * @param message the message to be displayed * @param description the description of this message * @param type the type of this notification */ public void notifyMessage(String message, String description, Notification.Type type) { Notification notification = new Notification("Message", type); notification.setCaption(message); notification.setDescription(description); notification.setDelayMsec(1000); if (getUI() != null) { if (getPage() != null) { notification.show(getUI().getPage()); } } }
/** * Method for displaying notification for the user. * * @param message the message to be displayed * @param description the description of this message * @param type the type of this notification */ public void notifyMessage(String message, String description, Notification.Type type) { Notification m_notification = new Notification("Message", type); m_notification.setCaption(message); m_notification.setDescription(description); m_notification.setDelayMsec(1000); if (getUI() != null) { if (getPage() != null) { m_notification.show(getUI().getPage()); } } }