@JsModule(value="./flow-component-renderer.js") public class Notification extends GeneratedVaadinNotification<Notification> implements HasComponents, HasTheme
vaadin-notification element.| Modifier and Type | Class and Description |
|---|---|
static class |
Notification.Position
Enumeration of all available positions for notification component
|
GeneratedVaadinNotification.OpenedChangeEvent<R extends GeneratedVaadinNotification<R>>| Constructor and Description |
|---|
Notification()
Default constructor.
|
Notification(Component... components)
Creates a notification with given components inside.
|
Notification(String text)
Creates a Notification with the given String rendered as its HTML text,
that does not close automatically.
|
Notification(String text,
int duration)
Creates a Notification with given String rendered as its HTML text and
given Integer rendered as its duration.
|
Notification(String text,
int duration,
Notification.Position position)
Creates a Notification with given text String, duration and position
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Component... components)
Adds the given components into this notification.
|
Registration |
addAttachListener(ComponentEventListener<AttachEvent> listener)
Adds a attach listener to this component.
|
void |
addComponentAtIndex(int index,
Component component)
Adds the given component into this notification at the given index.
|
Registration |
addDetachListener(ComponentEventListener<DetachEvent> listener)
Adds a detach listener to this component.
|
Registration |
addOpenedChangeListener(ComponentEventListener<GeneratedVaadinNotification.OpenedChangeEvent<Notification>> listener)
Adds a listener for
opened-changed events fired by the
webcomponent. |
void |
addThemeVariants(NotificationVariant... variants)
Adds theme variants to the component.
|
void |
close()
Closes the notification.
|
Stream<Component> |
getChildren()
Gets the child components of this component.
|
int |
getDuration()
Description copied from corresponding location in WebComponent:
|
Notification.Position |
getPosition()
Description copied from corresponding location in WebComponent:
|
boolean |
isOpened()
Description copied from corresponding location in WebComponent:
|
void |
open()
Opens the notification.
|
void |
remove(Component... components)
Remove the given components from this notification.
|
void |
removeAll()
Remove all the components from this notification.
|
void |
removeThemeVariants(NotificationVariant... variants)
Removes theme variants from the component.
|
void |
setDuration(int duration)
Description copied from corresponding location in WebComponent:
|
void |
setOpened(boolean opened)
Opens or closes the notification.
|
void |
setPosition(Notification.Position position)
Set position of the notification.
|
void |
setText(String text)
Set the text of the notification with given String
|
static Notification |
show(String text)
Shows a notification in the current page with given text.
|
static Notification |
show(String text,
int duration,
Notification.Position position)
Shows a notification in the current page with given text, duration and
position.
|
getDurationDouble, getPositionString, isOpenedBoolean, render, setDuration, setPositionaddListener, fireEvent, from, get, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadd, addComponentAsFirstisEnabled, setEnabledgetElementaddThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNamepublic Notification()
Note: To mix text and child components in notification that also supports
child components, use the Text component for the textual parts.
public Notification(String text)
text - the text of the Notificationpublic Notification(String text, int duration)
Set to 0 or a negative number to disable the notification
auto-closing.
text - the text of the Notificationduration - the duration in milliseconds to show the notificationpublic Notification(String text, int duration, Notification.Position position)
Set to 0 or a negative number to disable the notification
auto-closing.
text - the text of the notificationduration - the duration in milliseconds to show the notificationposition - the position of the notification. Valid enumerate values are
TOP_STRETCH, TOP_START, TOP_CENTER, TOP_END, MIDDLE,
BOTTOM_START, BOTTOM_CENTER, BOTTOM_END, BOTTOM_STRETCHpublic Notification(Component... components)
Note: To mix text and child components in a component that also supports
child components, use the Text component for the textual parts.
components - the components inside the notificationadd(Component...)public static Notification show(String text, int duration, Notification.Position position)
text - the text of the Notificationduration - the duration in milliseconds to show the notificationposition - the position of the notification. Valid enumerate values are
TOP_STRETCH, TOP_START, TOP_CENTER, TOP_END, MIDDLE,
BOTTOM_START, BOTTOM_CENTER, BOTTOM_END, BOTTOM_STRETCHpublic static Notification show(String text)
This is the convenience method for show(String, int, Position)
which uses default web-component values for duration (which is 5000 ms)
and position (Position.BOTTOM_START).
text - the text of the Notificationpublic void setText(String text)
NOTE: When mixing this method with Notification() and
Notification(Component...). Method will remove all the
components from the notification.
text - the text of the Notificationpublic void setPosition(Notification.Position position)
position - the position of the notification. Valid enumerate values are
TOP_STRETCH, TOP_START, TOP_CENTER, TOP_END, MIDDLE, BOTTOM_START, BOTTOM_CENTER, BOTTOM_END, BOTTOM_STRETCH,
not nullpublic Notification.Position getPosition()
Description copied from corresponding location in WebComponent:
Alignment of the notification in the viewport Valid values are
top-stretch|top-start|top-center|top-end|middle|bottom-start|bottom-center|bottom-end|bottom-stretch
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
The default position value is Position.BOTTOM_START.
Notification.Position property from the webcomponentpublic void open()
open in class GeneratedVaadinNotification<Notification>public void close()
Note: This method also removes the notification component from the DOM after closing it, unless you have added the component manually.
close in class GeneratedVaadinNotification<Notification>public void add(Component... components)
The elements in the DOM will not be children of the
<vaadin-notification> element, but will be inserted into an
overlay that is attached into the <body>.
NOTE: When mixing this method with Notification(String),
Notification(String, int) and
Notification(String, int, Position) method will remove the text
content.
add in interface HasComponentscomponents - the components to addpublic void remove(Component... components)
remove in interface HasComponentscomponents - the components to removepublic void addComponentAtIndex(int index,
Component component)
The element in the DOM will not be child of the
<vaadin-notification> element, but will be inserted into an
overlay that is attached into the <body>.
NOTE: When mixing this method with Notification(String),
Notification(String, int) and
Notification(String, int, Position) method will remove the text
content.
addComponentAtIndex in interface HasComponentsindex - the index, where the component will be added.component - the component to addpublic void removeAll()
removeAll in interface HasComponentspublic Stream<Component> getChildren()
Component
The default implementation finds child components by traversing each
child Element tree.
If the component is injected to a PolymerTemplate using the
@Id annotation the getChildren method will only return
children added from the server side and will not return any children
declared in the template file.
getChildren in class ComponentIdpublic void setOpened(boolean opened)
Note: You don't need to add the component anywhere before opening it.
Since <vaadin-notification>'s location in the DOM doesn't really
matter, opening a notification will automatically add it to the
<body> if it's not yet attached anywhere.
setOpened in class GeneratedVaadinNotification<Notification>opened - true to open the notification, false to close
itpublic boolean isOpened()
Description copied from corresponding location in WebComponent:
True if the notification is currently displayed.
This property is synchronized automatically from client side when a 'opened-changed' event happens.
opened property from the webcomponentpublic Registration addOpenedChangeListener(ComponentEventListener<GeneratedVaadinNotification.OpenedChangeEvent<Notification>> listener)
GeneratedVaadinNotificationopened-changed events fired by the
webcomponent.addOpenedChangeListener in class GeneratedVaadinNotification<Notification>listener - the listenerRegistration for removing the event listenerpublic void setDuration(int duration)
Description copied from corresponding location in WebComponent:
The duration in milliseconds to show the notification. Set to 0
or a negative number to disable the notification auto-closing.
duration - the value to setpublic int getDuration()
Description copied from corresponding location in WebComponent:
The duration in milliseconds to show the notification. Set to 0
or a negative number to disable the notification auto-closing.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
duration property from the webcomponentpublic Registration addAttachListener(ComponentEventListener<AttachEvent> listener)
Note: To listen for opening the notification, you should use
addOpenedChangeListener(ComponentEventListener).
addAttachListener in interface AttachNotifierlistener - the listener to add, not nullpublic Registration addDetachListener(ComponentEventListener<DetachEvent> listener)
Note: To listen for closing the notification, you should use
addOpenedChangeListener(ComponentEventListener), as the
component is not necessarily removed from the DOM when closing.
addDetachListener in interface DetachNotifierlistener - the listener to add, not nullpublic void addThemeVariants(NotificationVariant... variants)
variants - theme variants to addpublic void removeThemeVariants(NotificationVariant... variants)
variants - theme variants to removeCopyright © 2025. All rights reserved.