Package com.storedobject.vaadin
Class Alert
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.notification.Notification
com.storedobject.vaadin.Alert
- All Implemented Interfaces:
ClickNotifier,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.Component>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasText,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.notification.NotificationVariant>,Serializable
- Direct Known Subclasses:
Alert
public class Alert
extends com.vaadin.flow.component.notification.Notification
implements com.vaadin.flow.component.HasText, ClickNotifier
Slightly enhanced version of Vaadin's
Notification. Supports HTML text and the notification is "clickable" (an associated
action can be defined).- Author:
- Syam
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.notification.Notification
com.vaadin.flow.component.notification.Notification.OpenedChangeEvent, com.vaadin.flow.component.notification.Notification.PositionNested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
com.vaadin.flow.component.HasText.WhiteSpace -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAlert(StyledText htmlContent, Consumer<Alert> clickAction) Constructor.protectedAlert(StyledText htmlContent, Consumer<Alert> clickAction, com.vaadin.flow.component.notification.NotificationVariant style) Constructor.Constructor.Constructor.Constructor.Alert(String caption, String htmlText, com.vaadin.flow.component.notification.NotificationVariant style) Constructor.Constructor.Alert(String caption, String htmlText, Consumer<Alert> clickAction, com.vaadin.flow.component.notification.NotificationVariant style) Constructor.Constructor.Alert(String htmlText, Consumer<Alert> clickAction, com.vaadin.flow.component.notification.NotificationVariant style) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddClickListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.Component>> listener) voidclicked()This method is invoked when clicked on the alert.voiddelete()Delete (and close) the alert so that it's no more associated withApplication.booleanCheck whether this alert should be removed when closed or not.Get the click action associated with this alert.Get the content as "styled text".getText()Get the text of the alert.voidremoveClickListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.Component>> listener) Remove a listener.com.vaadin.flow.shared.RegistrationreplaceClickListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.Component>> oldListener, com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.Component>> newListener) Replace a listener.static voidsetDefaultPosition(com.vaadin.flow.component.notification.Notification.Position defaultPosition) Set the default position of alerts.voidSet some text on the alert.voidshow()Show the alert.Methods inherited from class com.vaadin.flow.component.notification.Notification
add, addAttachListener, addComponentAtIndex, addDetachListener, addOpenedChangeListener, close, getClassNames, getDuration, getPosition, getStyle, isAssertive, isOpened, onAttach, onDetach, open, setAssertive, setClassName, setDuration, setOpened, setPosition, show, show, showMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, addComponentAsFirst, remove, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, hasClassName, removeClassName, removeClassNames, setClassNameMethods inherited from interface com.vaadin.flow.component.HasText
getWhiteSpace, setWhiteSpaceMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariants
-
Constructor Details
-
Alert
-
Alert
-
Alert
-
Alert
-
Alert
Constructor.- Parameters:
htmlText- HTML textstyle- Style
-
Alert
-
Alert
-
Alert
-
Alert
Constructor.- Parameters:
htmlContent- HTML contentclickAction- Click action
-
Alert
protected Alert(StyledText htmlContent, Consumer<Alert> clickAction, com.vaadin.flow.component.notification.NotificationVariant style) Constructor.- Parameters:
htmlContent- HTML contentclickAction- Click actionstyle- Style
-
-
Method Details
-
addClickListener
public com.vaadin.flow.shared.Registration addClickListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.Component>> listener) - Specified by:
addClickListenerin interfacecom.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.Component>
-
removeClickListener
public void removeClickListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.Component>> listener) Description copied from interface:ClickNotifierRemove a listener.- Specified by:
removeClickListenerin interfaceClickNotifier- Parameters:
listener- Listener
-
replaceClickListener
public com.vaadin.flow.shared.Registration replaceClickListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.Component>> oldListener, com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<com.vaadin.flow.component.Component>> newListener) Description copied from interface:ClickNotifierReplace a listener.- Specified by:
replaceClickListenerin interfaceClickNotifier- Parameters:
oldListener- Old listenernewListener- New listener- Returns:
- Registration.
-
show
public void show()Show the alert. (Same asNotification.open()). -
clicked
public void clicked()This method is invoked when clicked on the alert. Default behaviour of this method is to execute the action that is already defined or if no action is defined, it will be closed. -
setText
Set some text on the alert. If the text is non-empty, alert will be shown.- Specified by:
setTextin interfacecom.vaadin.flow.component.HasText- Overrides:
setTextin classcom.vaadin.flow.component.notification.Notification- Parameters:
text- Text to show
-
getText
Get the text of the alert.- Specified by:
getTextin interfacecom.vaadin.flow.component.HasText- Returns:
- Text.
-
getContent
-
getClickAction
-
delete
public void delete()Delete (and close) the alert so that it's no more associated withApplication. -
deleteOnClose
public boolean deleteOnClose()Check whether this alert should be removed when closed or not.- Returns:
- True if this should be removed when closed.
-
setDefaultPosition
public static void setDefaultPosition(com.vaadin.flow.component.notification.Notification.Position defaultPosition) Set the default position of alerts.- Parameters:
defaultPosition- Position.
-