* Shows a notification message.
*
* @see Notification
- * @see #showNotification(String)
- * @see #showNotification(String, int)
- * @see #showNotification(String, String)
- * @see #showNotification(String, String, int)
*
* @param notification
* The notification message to show
+ *
+ * @deprecated Use Notification.show(Page) instead.
*/
+ @Deprecated
public void showNotification(Notification notification) {
addNotification(notification);
}
return htmlContentAllowed;
}
- public void show() {
- Page.getCurrent().showNotification(this);
+ /**
+ * Shows this notification on a Page.
+ *
+ * @param page
+ * The page on which the notification should be shown
+ */
+ public void show(Page page) {
+ // TODO Can avoid deprecated API when Notification extends Extension
+ page.showNotification(this);
}
/**
* Care should be taken to to avoid XSS vulnerabilities as the caption is
* rendered as html.
*
- * @see #showNotification(Notification)
- * @see Notification
+ * @see #Notification(String)
+ * @see #show(Page)
*
* @param caption
* The message
*/
public static void show(String caption) {
- new Notification(caption).show();
+ new Notification(caption).show(Page.getCurrent());
}
/**
* Care should be taken to to avoid XSS vulnerabilities as the caption is
* rendered as html.
*
- * @see #showNotification(Notification)
- * @see Notification
+ * @see #Notification(String, int)
+ * @see #show(Page)
*
* @param caption
* The message
* The message type
*/
public static void show(String caption, int type) {
- new Notification(caption, type).show();
- }
-
- /**
- * Shows a notification consisting of a bigger caption and a smaller
- * description on the middle of the current page. 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
- *
- */
- public static void show(String caption, String description) {
- new Notification(caption, description).show();
- }
-
- /**
- * 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
- */
- public static void show(String caption, String description, int type) {
-
- new Notification(caption, description, type).show();
- }
-
- /**
- * 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 avoid XSS vulnerabilities if html content is
- * allowed.
- *
- * @see #showNotification(Notification)
- * @see Notification
- *
- * @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 static void show(String caption, String description, int type,
- boolean htmlContentAllowed) {
- new Notification(caption, description, type, htmlContentAllowed).show();
+ new Notification(caption, type).show(Page.getCurrent());
}
}
\ No newline at end of file
*/
package com.vaadin.tests;
+import com.vaadin.terminal.Page;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CustomComponent;
public void buttonClick(ClickEvent event) {
try {
p3.addComponent(p2);
- Notification.show("ERROR", "This should have failed",
- Notification.TYPE_ERROR_MESSAGE);
+ new Notification("ERROR", "This should have failed",
+ Notification.TYPE_ERROR_MESSAGE).show(Page
+ .getCurrent());
} catch (Exception e) {
- Notification.show("OK", "threw, as expected",
- Notification.TYPE_ERROR_MESSAGE);
+ new Notification("OK", "threw, as expected",
+ Notification.TYPE_ERROR_MESSAGE).show(Page
+ .getCurrent());
}
}
p.addComponent(p2);
try {
p3.addComponent(p);
- Notification.show("ERROR", "This should have failed",
- Notification.TYPE_ERROR_MESSAGE);
+ new Notification("ERROR", "This should have failed",
+ Notification.TYPE_ERROR_MESSAGE).show(Page
+ .getCurrent());
} catch (Exception e) {
- Notification.show("OK", "threw, as expected",
- Notification.TYPE_ERROR_MESSAGE);
+ new Notification("OK", "threw, as expected",
+ Notification.TYPE_ERROR_MESSAGE).show(Page
+ .getCurrent());
}
}
package com.vaadin.tests.components.notification;
+import com.vaadin.terminal.Page;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
public void buttonClick(ClickEvent event) {
Notification n = new Notification(tf.getValue(),
(Integer) type.getValue());
- n.show();
+ n.show(Page.getCurrent());
}
}
package com.vaadin.tests.components.notification;
+import com.vaadin.terminal.Page;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
public void buttonClick(ClickEvent event) {
Notification n = makeNotification();
- n.show();
+ n.show(Page.getCurrent());
}
private Notification makeNotification() {
tf.setEnabled((request.getPortletMode() == PortletMode.EDIT));
// Show notification about current mode and state
- Notification.show(
- "Portlet status",
- "Mode: " + request.getPortletMode() + " State: "
- + request.getWindowState(),
- Notification.TYPE_WARNING_MESSAGE);
+ new Notification("Portlet status", "Mode: "
+ + request.getPortletMode() + " State: "
+ + request.getWindowState(),
+ Notification.TYPE_WARNING_MESSAGE).show(getPage());
// Display current user info
Map<?, ?> uinfo = (Map<?, ?>) request
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.event.Action;
import com.vaadin.terminal.ExternalResource;
+import com.vaadin.terminal.Page;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.gwt.client.ui.label.ContentMode;
Button show = new Button("Humanized Notification",
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- Notification.show(title.getValue(), message.getValue());
-
+ new Notification(title.getValue(), message.getValue())
+ .show(Page.getCurrent());
}
});
l.addComponent(show);
l.addComponent(new Label("Warning", ContentMode.XHTML));
show = new Button("Warning Notification", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- Notification.show(title.getValue(), message.getValue(),
- Notification.TYPE_WARNING_MESSAGE);
+ new Notification(title.getValue(), message.getValue(),
+ Notification.TYPE_WARNING_MESSAGE).show(Page
+ .getCurrent());
}
});
l.addComponent(new Label("Error", ContentMode.XHTML));
show = new Button("Error Notification", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- Notification.show(title.getValue(), message.getValue(),
- Notification.TYPE_ERROR_MESSAGE);
+ new Notification(title.getValue(), message.getValue(),
+ Notification.TYPE_ERROR_MESSAGE).show(Page.getCurrent());
}
});
l.addComponent(new Label("Tray", ContentMode.XHTML));
show = new Button("Tray Notification", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- Notification.show(title.getValue(), message.getValue(),
- Notification.TYPE_TRAY_NOTIFICATION);
+ new Notification(title.getValue(), message.getValue(),
+ Notification.TYPE_TRAY_NOTIFICATION).show(Page
+ .getCurrent());
}
});