Class CustomizedSystemMessages
- All Implemented Interfaces:
Serializable
Vaadin gets the SystemMessages from the SystemMessagesProvider
configured in VaadinService. You can customize this by creating a
VaadinServiceInitListener that sets an instance of
SystemMessagesProvider to
VaadinService.setSystemMessagesProvider(SystemMessagesProvider), that
in turns creates instances of CustomizedSystemMessages.
The default behavior is to show a notification, and reload the browser page
once the user clicks the message.
However, only for session expiration, that default is to reload the page
without any notification. Instead of reloading the page, you can set a
specific URL that the user is taken to.
Setting both caption and message to null will reload the page (or go to the
specified URL) without displaying a notification.
set*NotificationEnabled(false) will achieve the same thing.
The situations are:
- Session expired: the user session has expired, usually due to inactivity.
- Cookies disabled: the cookie support is disabled in the browser.
- Internal error: unhandled critical server error (e.g out of memory, database crash)
- Since:
- 1.0
- See Also:
-
Field Summary
Fields inherited from class com.vaadin.flow.server.SystemMessages
cookiesDisabledCaption, cookiesDisabledMessage, cookiesDisabledNotificationEnabled, cookiesDisabledURL, internalErrorCaption, internalErrorMessage, internalErrorNotificationEnabled, internalErrorURL, sessionExpiredCaption, sessionExpiredMessage, sessionExpiredNotificationEnabled, sessionExpiredURL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetCookiesDisabledCaption(String cookiesDisabledCaption) Sets the caption to show in an "cookies disabled" notification.voidsetCookiesDisabledMessage(String cookiesDisabledMessage) Sets the message to show in a "cookies disabled" notification.voidsetCookiesDisabledNotificationEnabled(boolean cookiesDisabledNotificationEnabled) Sets whether a "cookies disabled" notification should be shown to the end user.voidsetCookiesDisabledURL(String cookiesDisabledURL) Sets the URL the user will be redirected to after dismissing a "cookies disabled" message.voidsetInternalErrorCaption(String internalErrorCaption) Sets the caption to show in an "internal error" notification.voidsetInternalErrorMessage(String internalErrorMessage) Sets the message to show in an "internal error" notification.voidsetInternalErrorNotificationEnabled(boolean internalErrorNotificationEnabled) Sets whether an "internal error" notification should be shown to the end user.voidsetInternalErrorURL(String internalErrorURL) Sets the URL the user will be redirected to after dismissing an "internal error" message.voidsetSessionExpiredCaption(String sessionExpiredCaption) Sets the caption to show in a "session expired" notification.voidsetSessionExpiredMessage(String sessionExpiredMessage) Sets the message to show in a "session expired" notification.voidsetSessionExpiredNotificationEnabled(boolean sessionExpiredNotificationEnabled) Sets whether a "session expired" notification should be shown to the end user.voidsetSessionExpiredURL(String sessionExpiredURL) Sets the URL the user will be redirected to after dismissing a "session expired" message.Methods inherited from class com.vaadin.flow.server.SystemMessages
getCookiesDisabledCaption, getCookiesDisabledMessage, getCookiesDisabledURL, getInternalErrorCaption, getInternalErrorMessage, getInternalErrorURL, getSessionExpiredCaption, getSessionExpiredMessage, getSessionExpiredURL, isCookiesDisabledNotificationEnabled, isInternalErrorNotificationEnabled, isSessionExpiredNotificationEnabled
-
Constructor Details
-
CustomizedSystemMessages
public CustomizedSystemMessages()
-
-
Method Details
-
setSessionExpiredURL
Sets the URL the user will be redirected to after dismissing a "session expired" message. Default value is null.- Parameters:
sessionExpiredURL- the URL to redirect to, or null to refresh the page
-
setSessionExpiredNotificationEnabled
public void setSessionExpiredNotificationEnabled(boolean sessionExpiredNotificationEnabled) Sets whether a "session expired" notification should be shown to the end user. If the notification is disabled the user will be immediately redirected to the URL returned bySystemMessages.getSessionExpiredURL(). By default, the "session expired" notification is disabled.- Parameters:
sessionExpiredNotificationEnabled-trueto show the notification to the end user,falseto redirect directly
-
setSessionExpiredCaption
Sets the caption to show in a "session expired" notification.If both
SystemMessages.getSessionExpiredCaption()andSystemMessages.getSessionExpiredMessage()return null, the user will automatically be forwarded to the URL returned bySystemMessages.getSessionExpiredURL()when the session expires.- Parameters:
sessionExpiredCaption- The caption to show ornullto show no caption.
-
setSessionExpiredMessage
Sets the message to show in a "session expired" notification.If both
SystemMessages.getSessionExpiredCaption()andSystemMessages.getSessionExpiredMessage()return null, the user will automatically be forwarded to the URL returned bySystemMessages.getSessionExpiredURL()when the session expires.- Parameters:
sessionExpiredMessage- The message to show ornullto show no message.
-
setInternalErrorURL
Sets the URL the user will be redirected to after dismissing an "internal error" message. Default value is null.- Parameters:
internalErrorURL- the URL to redirect to, or null to refresh the page
-
setInternalErrorNotificationEnabled
public void setInternalErrorNotificationEnabled(boolean internalErrorNotificationEnabled) Sets whether an "internal error" notification should be shown to the end user. If the notification is disabled the user will be immediately redirected to the URL returned bySystemMessages.getInternalErrorURL(). By default, the "internal error" notification is enabled.- Parameters:
internalErrorNotificationEnabled-trueto show the notification to the end user,falseto redirect directly
-
setInternalErrorCaption
Sets the caption to show in an "internal error" notification.- Parameters:
internalErrorCaption- The caption to show ornullto show no caption.
-
setInternalErrorMessage
Sets the message to show in an "internal error" notification.- Parameters:
internalErrorMessage- The message to show ornullto show no message.
-
setCookiesDisabledURL
Sets the URL the user will be redirected to after dismissing a "cookies disabled" message. Default value is null.- Parameters:
cookiesDisabledURL- the URL to redirect to, or null to refresh the page
-
setCookiesDisabledNotificationEnabled
public void setCookiesDisabledNotificationEnabled(boolean cookiesDisabledNotificationEnabled) Sets whether a "cookies disabled" notification should be shown to the end user. If the notification is disabled the user will be immediately redirected to the URL returned bySystemMessages.getCookiesDisabledURL(). By default, the "cookies disabled" notification is enabled.- Parameters:
cookiesDisabledNotificationEnabled-trueto show the notification to the end user,falseto redirect directly
-
setCookiesDisabledCaption
Sets the caption to show in an "cookies disabled" notification.- Parameters:
cookiesDisabledCaption- The caption to show ornullto show no caption.
-
setCookiesDisabledMessage
Sets the message to show in a "cookies disabled" notification.- Parameters:
cookiesDisabledMessage- The message to show ornullto show no message.
-