@JsModule(value="./flow-component-renderer.js") public class Notification extends GeneratedVaadinNotification<Notification> implements com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.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(com.vaadin.flow.component.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(com.vaadin.flow.component.Component... components)
Adds the given components into this notification.
|
com.vaadin.flow.shared.Registration |
addAttachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.AttachEvent> listener) |
void |
addComponentAtIndex(int index,
com.vaadin.flow.component.Component component)
Adds the given component into this notification at the given index.
|
com.vaadin.flow.shared.Registration |
addDetachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.DetachEvent> listener) |
com.vaadin.flow.shared.Registration |
addOpenedChangeListener(com.vaadin.flow.component.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<com.vaadin.flow.component.Component> |
getChildren() |
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(com.vaadin.flow.component.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, setDuration, setPositionaddListener, fireEvent, from, get, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisiblepublic 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(com.vaadin.flow.component.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(com.vaadin.flow.component.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 com.vaadin.flow.component.HasComponentscomponents - the components to addpublic void remove(com.vaadin.flow.component.Component... components)
remove in interface com.vaadin.flow.component.HasComponentscomponents - the components to removepublic void addComponentAtIndex(int index,
com.vaadin.flow.component.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 com.vaadin.flow.component.HasComponentsindex - the index, where the component will be added.component - the component to addpublic void removeAll()
removeAll in interface com.vaadin.flow.component.HasComponentspublic Stream<com.vaadin.flow.component.Component> getChildren()
getChildren in class com.vaadin.flow.component.Componentpublic 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 com.vaadin.flow.shared.Registration addOpenedChangeListener(com.vaadin.flow.component.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 com.vaadin.flow.shared.Registration addAttachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.AttachEvent> listener)
Note: To listen for opening the notification, you should use
addOpenedChangeListener(ComponentEventListener).
addAttachListener in interface com.vaadin.flow.component.AttachNotifierpublic com.vaadin.flow.shared.Registration addDetachListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.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 com.vaadin.flow.component.DetachNotifierpublic void addThemeVariants(NotificationVariant... variants)
variants - theme variants to addpublic void removeThemeVariants(NotificationVariant... variants)
variants - theme variants to removeCopyright © 2022. All rights reserved.