/** * 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); }
public static Notification build(final String caption, final String description, final int delayMsec, final boolean htmlContentAllowed) { Notification notification = new Notification(caption); notification.setDescription(description); notification.setStyleName("tray dark small closable login-help"); notification.setPosition(Position.BOTTOM_CENTER); notification.setDelayMsec(delayMsec); notification.setHtmlContentAllowed(htmlContentAllowed); return notification; }
@Override public void buttonClick(ClickEvent event) { String caption = "Help"; if(getCaption() != null && !getCaption().isEmpty()) { caption = "Help for \"" + getCaption(); } caption = caption + "<br/><br/>(Click here to close)"; Notification notify = new Notification(caption, Notification.Type.HUMANIZED_MESSAGE); notify.setHtmlContentAllowed(true); notify.setDescription(field.getDescription()); notify.setDelayMsec(-1); notify.show(UI.getCurrent().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()); } } }
+ "There might be too many users using this service right now.", Notification.Type.WARNING_MESSAGE); n.setDescription("<p><strong>Please try again later.</strong> If the error persists inform the administrator of this server.</p>" + "<p>Click on this message to close it.</p>" + "<p style=\"font-size:9pt;color:gray;\">Pinguin picture by Polar Cruises [CC BY 2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons</p>");
/** * 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()); } } }
/** * 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()); } } } }