com.vaadin.flow.component.notification.
Class GeneratedVaadinNotification<R extends GeneratedVaadinNotification<R>>
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.notification.GeneratedVaadinNotification<R>
-
All Implemented Interfaces:
Direct Known Subclasses:
@Tag(value="vaadin-notification") @NpmPackage(value="@vaadin/vaadin-notification", version="1.6.2") @JsModule(value="@vaadin/vaadin-notification/src/vaadin-notification.js") public abstract class GeneratedVaadinNotification<R extends GeneratedVaadinNotification<R>> extends Component
Description copied from corresponding location in WebComponent:
<vaadin-notification>
is a Web Component providing accessible and customizable notifications (toasts). The content of the notification can be populated in two ways: imperatively by using renderer callback function and declaratively by using Polymer's Templates.Rendering
By default, the notification uses the content provided by using the renderer callback function.
The renderer function provides
root
,notification
arguments. Generate DOM content, append it to theroot
element and control the state of the host element by accessingnotification
. Before generating new content, users are able to check if there is already content inroot
for reusing it.<vaadin-notification id="notification"></vaadin-notification>
const notification = document.querySelector('#notification'); notification.renderer = function(root) root.textContent = "Your work has been saved";
;}Renderer is called on the opening of the notification. DOM generated during the renderer call can be reused in the next renderer call and will be provided with the
root
argument. On first call it will be empty.Polymer Templates
Alternatively, the content can be provided with Polymer's Template. Notification finds the first child template and uses that in case renderer callback function is not provided. You can also set a custom template using the
template
property.<vaadin-notification> <template> Your work has been saved </template> </vaadin-notification>
Styling
<vaadin-notification>
uses<vaadin-notification-card>
internal themable component as the actual visible notification cards. See the stylable parts the<vaadin-notification-card>
API.Note: the
theme
attribute value set on<vaadin-notification>
is propagated to the internal<vaadin-notification-card>
.See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
GeneratedVaadinNotification.OpenedChangeEvent<R extends GeneratedVaadinNotification<R>>
-
Constructor Summary
Constructors Constructor and Description GeneratedVaadinNotification()
-
Method Summary
All Methods Modifier and Type Method and Description protected Registration
addOpenedChangeListener(ComponentEventListener<GeneratedVaadinNotification.OpenedChangeEvent<R>> listener)
Adds a listener for
opened-changed
events fired by the webcomponent.protected void
close()
Description copied from corresponding location in WebComponent:
protected double
getDurationDouble()
Description copied from corresponding location in WebComponent:
protected String
getPositionString()
Description copied from corresponding location in WebComponent:
protected boolean
isOpenedBoolean()
Description copied from corresponding location in WebComponent:
protected void
open()
Description copied from corresponding location in WebComponent:
protected void
render()
Description copied from corresponding location in WebComponent:
protected void
setDuration(double duration)
Description copied from corresponding location in WebComponent:
protected void
setOpened(boolean opened)
Description copied from corresponding location in WebComponent:
protected void
setPosition(String position)
Description copied from corresponding location in WebComponent:
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
-
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
-
-
-
Method Detail
-
getDurationDouble
protected double getDurationDouble()
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.
Returns:
the
duration
property from the webcomponent
-
setDuration
protected void setDuration(double 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.Parameters:
duration
- the double value to set
-
isOpenedBoolean
@Synchronize(property="opened", value="opened-changed") protected boolean isOpenedBoolean()
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.
Returns:
the
opened
property from the webcomponent
-
setOpened
protected void setOpened(boolean opened)
Description copied from corresponding location in WebComponent:
True if the notification is currently displayed.
Parameters:
opened
- the boolean value to set
-
getPositionString
protected String getPositionString()
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.
Returns:
the
position
property from the webcomponent
-
setPosition
protected void setPosition(String position)
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
Parameters:
position
- the String value to set
-
render
protected void render()
Description copied from corresponding location in WebComponent:
Manually invoke existing renderer.
-
open
protected void open()
Description copied from corresponding location in WebComponent:
Opens the notification.
-
close
protected void close()
Description copied from corresponding location in WebComponent:
Closes the notification.
-
addOpenedChangeListener
protected Registration addOpenedChangeListener(ComponentEventListener<GeneratedVaadinNotification.OpenedChangeEvent<R>> listener)
Adds a listener for
opened-changed
events fired by the webcomponent.Parameters:
listener
- the listenerReturns:
a
Registration
for removing the event listener
-
-