Class IdleNotification
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasStyle,Serializable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic enumstatic classstatic classstatic class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.IdleNotification(int secondsBeforeNotification) Creates an idle notification with the default message that will be displayed to the user at the specified number of seconds before session timeout.IdleNotification(String message, int secondsBeforeNotification) Creates an idle notification with the specified message that will be displayed to the user at the specified number of seconds before session timeout.IdleNotification(String message, int secondsBeforeNotification, int maxInactiveInterval) Creates an idle notification with the specified message that will be displayed to the user at the specified number of seconds before session timeout.IdleNotification(String message, int secondsBeforeNotification, int maxInactiveInterval, String redirectAtTimeoutUrl) Creates an idle notification with the specified message that will be displayed to the user at the specified number of seconds before session timeout.IdleNotification(String message, int secondsBeforeNotification, String redirectAtTimeoutUrl) Creates an idle notification with the specified message that will be displayed to the user at the specified number of seconds before session timeout. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a button to close the notification without poking the servercom.vaadin.flow.shared.RegistrationaddCloseListener(com.vaadin.flow.component.ComponentEventListener<IdleNotification.CloseEvent> listener) Adds a close handlervoidaddExtendSessionButton(String caption) Add a button to the notification that allows the user to poke the server, thereby extending the sessioncom.vaadin.flow.shared.RegistrationaddExtendSessionListener(com.vaadin.flow.component.ComponentEventListener<IdleNotification.ExtendSessionEvent> listener) Adds a session extend handlercom.vaadin.flow.shared.RegistrationaddOpenListener(com.vaadin.flow.component.ComponentEventListener<IdleNotification.OpenEvent> listener) Adds a open handlervoidaddRedirectButton(String caption, String url) Add a button to the notification that allows the user to be immediately redirected to a different url (e.g.com.vaadin.flow.shared.RegistrationaddRedirectListener(com.vaadin.flow.component.ComponentEventListener<IdleNotification.RedirectEvent> listener) Adds a redirect handlercom.vaadin.flow.shared.RegistrationaddTimeoutListener(com.vaadin.flow.component.ComponentEventListener<IdleNotification.TimeoutEvent> listener) Adds a timeout handlerGet the message displayed to the user after the session expiresintGet the number of seconds until the session times-outGet the text of the notificationGet the URL to redirect the page to upon session timeoutintGets the number of seconds before session times-out at which point the notification will be displayed to the userbooleanbooleanvoidRemove the close ButtonvoidRemove the extend-session buttonvoidRemove the redirect buttonvoidsetAfterExpiredMessage(String afterExpiredMessage) Set the message displayed to the user after the session expiresvoidsetCloseNotificationOnOutsideClick(boolean closeNotificationOnOutsideClick) Determines whether an outside click would close the notification without poking the servervoidsetExtendSessionOnOutsideClick(boolean extendSessionOnOutsideClick) Determines whether an outside click would poke the server (thereby extending the session)voidsetMaxInactiveInterval(int maxInactiveInterval) Set the number of seconds until the session times-outvoidsetMessage(String message) Set the text of the notification with given StringvoidsetRedirectAtTimeoutUrl(String redirectAtTimeoutUrl) The URL to redirect the page to upon session timeout.voidsetSecondsBeforeNotification(int secondsBeforeNotification) Sets the number of seconds before session times-out at which point the notification will be displayed to the userMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, 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.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
DEFAULT_SECONDS_BEFORE_NOTIFICATION
public static final int DEFAULT_SECONDS_BEFORE_NOTIFICATION- See Also:
-
DEFAULT_BEFORE_EXPIRE_MESSAGE
-
DEFAULT_AFTER_EXPIRE_MESSAGE
- See Also:
-
-
Constructor Details
-
IdleNotification
Default constructor. Creates an idle notification with defaults.maxInactiveIntervalis obtained viaVaadinSession.getCurrent().getSession().getMaxInactiveInterval()- Throws:
IllegalArgumentException- If eithersecondsBeforeNotificationormaxInactiveIntervalvalue is smaller than 1 seconds, or ifsecondsBeforeNotificationvalue is larger than, or equal to,maxInactiveInterval.
-
IdleNotification
Creates an idle notification with the default message that will be displayed to the user at the specified number of seconds before session timeout.maxInactiveIntervalis obtained viaVaadinSession.getCurrent().getSession().getMaxInactiveInterval()- Parameters:
secondsBeforeNotification- the number of seconds before session times-out at which point the notification will be displayed to the user- Throws:
IllegalArgumentException- If eithersecondsBeforeNotificationormaxInactiveIntervalvalue is smaller than 1 seconds, or ifsecondsBeforeNotificationvalue is larger than, or equal to,maxInactiveInterval.
-
IdleNotification
public IdleNotification(String message, int secondsBeforeNotification) throws IllegalArgumentException Creates an idle notification with the specified message that will be displayed to the user at the specified number of seconds before session timeout.maxInactiveIntervalis obtained viaVaadinSession.getCurrent().getSession().getMaxInactiveInterval()- Parameters:
message- the text of the notificationsecondsBeforeNotification- the number of seconds before session times-out at which point the notification will be displayed to the user- Throws:
IllegalArgumentException- If eithersecondsBeforeNotificationormaxInactiveIntervalvalue is smaller than 1 seconds, or ifsecondsBeforeNotificationvalue is larger than, or equal to,maxInactiveInterval.
-
IdleNotification
public IdleNotification(String message, int secondsBeforeNotification, String redirectAtTimeoutUrl) throws IllegalArgumentException Creates an idle notification with the specified message that will be displayed to the user at the specified number of seconds before session timeout.maxInactiveIntervalis obtained viaVaadinSession.getCurrent().getSession().getMaxInactiveInterval()- Parameters:
message- the text of the notificationsecondsBeforeNotification- the number of seconds before session times-out at which point the notification will be displayed to the userredirectAtTimeoutUrl- The URL to redirect the page to upon session timeout- Throws:
IllegalArgumentException- If eithersecondsBeforeNotificationormaxInactiveIntervalvalue is smaller than 1 seconds, or ifsecondsBeforeNotificationvalue is larger than, or equal to,maxInactiveInterval.
-
IdleNotification
public IdleNotification(String message, int secondsBeforeNotification, int maxInactiveInterval, String redirectAtTimeoutUrl) throws IllegalArgumentException Creates an idle notification with the specified message that will be displayed to the user at the specified number of seconds before session timeout. This constructor allows the specification of an arbitrarymaxInactiveInterval, which doesn't have to coincide with the one defined for the underlying HttpSession.- Parameters:
message- the text of the notificationsecondsBeforeNotification- the number of seconds before session times-out at which point the notification will be displayed to the usermaxInactiveInterval- the number of seconds until the session times-outredirectAtTimeoutUrl- The URL to redirect the page to upon session timeout- Throws:
IllegalArgumentException- If eithersecondsBeforeNotificationormaxInactiveIntervalvalue is smaller than 1 seconds, or ifsecondsBeforeNotificationvalue is larger than, or equal to,maxInactiveInterval.
-
IdleNotification
public IdleNotification(String message, int secondsBeforeNotification, int maxInactiveInterval) throws IllegalArgumentException Creates an idle notification with the specified message that will be displayed to the user at the specified number of seconds before session timeout. This constructor allows the specification of an arbitrarymaxInactiveInterval, which doesn't have to coincide with the one defined for the underlying HttpSession.- Parameters:
message- the text of the notificationsecondsBeforeNotification- the number of seconds before session times-out at which point the notification will be displayed to the usermaxInactiveInterval- the number of seconds until the session times-out- Throws:
IllegalArgumentException- If eithersecondsBeforeNotificationormaxInactiveIntervalvalue is smaller than 1 seconds, or ifsecondsBeforeNotificationvalue is larger than, or equal to,maxInactiveInterval.
-
-
Method Details
-
addCloseButton
public void addCloseButton()Adds a button to close the notification without poking the server -
removeCloseButton
public void removeCloseButton()Remove the close Button -
getMessage
Get the text of the notification- Returns:
- the text of the notification
-
setMessage
Set the text of the notification with given StringNOTE:
IdleNotification.MessageFormattingcan be used to format the message- Parameters:
message- the text of the Notification
-
addExtendSessionButton
Add a button to the notification that allows the user to poke the server, thereby extending the session -
removeExtendSessionButton
public void removeExtendSessionButton()Remove the extend-session button -
addRedirectButton
Add a button to the notification that allows the user to be immediately redirected to a different url (e.g. a logout url) -
removeRedirectButton
public void removeRedirectButton()Remove the redirect button -
getRedirectAtTimeoutUrl
Get the URL to redirect the page to upon session timeout -
setRedirectAtTimeoutUrl
The URL to redirect the page to upon session timeout. Setting this value to null will disable URL redirection upon timeout -
getAfterExpiredMessage
Get the message displayed to the user after the session expires -
setAfterExpiredMessage
Set the message displayed to the user after the session expiresNOTE: this message would only be displayed if
redirectAtTimeoutUrlis not set -
getMaxInactiveInterval
public int getMaxInactiveInterval()Get the number of seconds until the session times-outNOTE: This getter's return value doesn't have to coincide with the one defined for the underlying HttpSession.
-
setMaxInactiveInterval
Set the number of seconds until the session times-outNOTE: This setter allows the specification of an arbitrary
maxInactiveInterval, which doesn't have to coincide with the one defined for the underlying HttpSession.- Throws:
IllegalArgumentException- IfmaxInactiveIntervalvalue is smaller than 1 seconds, or ifsecondsBeforeNotificationvalue is larger than, or equal to,maxInactiveInterval.
-
getSecondsBeforeNotification
public int getSecondsBeforeNotification()Gets the number of seconds before session times-out at which point the notification will be displayed to the user -
setSecondsBeforeNotification
public void setSecondsBeforeNotification(int secondsBeforeNotification) throws IllegalArgumentException Sets the number of seconds before session times-out at which point the notification will be displayed to the user- Throws:
IllegalArgumentException- IfsecondsBeforeNotificationvalue is smaller than 1 seconds, or ifsecondsBeforeNotificationvalue is larger than, or equal to,maxInactiveInterval.
-
isExtendSessionOnOutsideClick
public boolean isExtendSessionOnOutsideClick() -
setExtendSessionOnOutsideClick
public void setExtendSessionOnOutsideClick(boolean extendSessionOnOutsideClick) Determines whether an outside click would poke the server (thereby extending the session) -
isCloseNotificationOnOutsideClick
public boolean isCloseNotificationOnOutsideClick() -
setCloseNotificationOnOutsideClick
public void setCloseNotificationOnOutsideClick(boolean closeNotificationOnOutsideClick) Determines whether an outside click would close the notification without poking the serverNOTE: this would only have an effect if (
extendSessionOnOutsideClick== false) -
addOpenListener
public com.vaadin.flow.shared.Registration addOpenListener(com.vaadin.flow.component.ComponentEventListener<IdleNotification.OpenEvent> listener) Adds a open handler -
addCloseListener
public com.vaadin.flow.shared.Registration addCloseListener(com.vaadin.flow.component.ComponentEventListener<IdleNotification.CloseEvent> listener) Adds a close handler -
addExtendSessionListener
public com.vaadin.flow.shared.Registration addExtendSessionListener(com.vaadin.flow.component.ComponentEventListener<IdleNotification.ExtendSessionEvent> listener) Adds a session extend handler -
addRedirectListener
public com.vaadin.flow.shared.Registration addRedirectListener(com.vaadin.flow.component.ComponentEventListener<IdleNotification.RedirectEvent> listener) Adds a redirect handler -
addTimeoutListener
public com.vaadin.flow.shared.Registration addTimeoutListener(com.vaadin.flow.component.ComponentEventListener<IdleNotification.TimeoutEvent> listener) Adds a timeout handler
-