/** * Shows a notification message on the middle of the UI. The message * automatically disappears ("humanized message"). * * Care should be taken to to avoid XSS vulnerabilities as the caption is * rendered as html. * * @see #showNotification(Notification) * @see Notification * * @param caption * The message * * @deprecated As of 7.0, use Notification.show instead but be aware that * Notification.show does not allow HTML. */ @Deprecated public void showNotification(String caption) { Notification notification = new Notification(caption); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); }
/** * Shows a notification consisting of a bigger caption and a smaller * description on the middle of the UI. The message automatically disappears * ("humanized message"). * * Care should be taken to to avoid XSS vulnerabilities as the caption and * description are rendered as html. * * @see #showNotification(Notification) * @see Notification * * @param caption * The caption of the message * @param description * The message description * * @deprecated As of 7.0, use new Notification(...).show(Page) instead but * be aware that HTML by default not allowed. */ @Deprecated public void showNotification(String caption, String description) { Notification notification = new Notification(caption, description); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); }
/** * Shows a notification message the UI. The position and behavior of the * message depends on the type, which is one of the basic types defined in * {@link Notification}, for instance Notification.TYPE_WARNING_MESSAGE. * * Care should be taken to to avoid XSS vulnerabilities as the caption is * rendered as html. * * @see #showNotification(Notification) * @see Notification * * @param caption * The message * @param type * The message type * * @deprecated As of 7.0, use Notification.show instead but be aware that * Notification.show does not allow HTML. */ @Deprecated public void showNotification(String caption, Notification.Type type) { Notification notification = new Notification(caption, type); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); }
/** * Shows a notification consisting of a bigger caption and a smaller * description. The position and behavior of the message depends on the * type, which is one of the basic types defined in {@link Notification} , * for instance Notification.TYPE_WARNING_MESSAGE. * * Care should be taken to to avoid XSS vulnerabilities as the caption and * description are rendered as html. * * @see #showNotification(Notification) * @see Notification * * @param caption * The caption of the message * @param description * The message description * @param type * The message type * * @deprecated As of 7.0, use new Notification(...).show(Page) instead but * be aware that HTML by default not allowed. */ @Deprecated public void showNotification(String caption, String description, Notification.Type type) { Notification notification = new Notification(caption, description, type); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); }
/** * 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()); }
+ "<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>"); n.setIcon(PINGUIN_IMAGE); n.setHtmlContentAllowed(true); n.setDelayMsec(15000);
@Override public void show() { com.vaadin.ui.Notification vNotification = new com.vaadin.ui.Notification(caption, description, convertType(notificationType)); if (hideDelayMs != DELAY_DEFAULT) { vNotification.setDelayMsec(hideDelayMs); } else { setNotificationDelayMsec(vNotification, notificationType); } if (position != Position.DEFAULT) { vNotification.setPosition(com.vaadin.shared.Position.valueOf(position.name())); } vNotification.setHtmlContentAllowed(contentMode == ContentMode.HTML); if (styleName != null) { vNotification.setStyleName(styleName); } vNotification.show(ui.getPage()); } }