com.vaadin.flow.server.
Class CustomizedSystemMessages
- java.lang.Object
-
- com.vaadin.flow.server.SystemMessages
-
- com.vaadin.flow.server.CustomizedSystemMessages
-
All Implemented Interfaces:
public class CustomizedSystemMessages extends SystemMessages
Contains the system messages used to notify the user about various critical situations that can occur.
Vaadin gets the SystemMessages from your application by calling a static getSystemMessages() method. By default the Application.getSystemMessages() is used. You can customize this by defining a static MyApplication.getSystemMessages() and returning CustomizedSystemMessages. Note that getSystemMessages() is static - changing the system messages will by default change the message for all users of the application.
The default behavior is to show a notification, and restart the application the user clicks the message.
Instead of restarting the application, you can set a specific URL that the user is taken to.
Setting both caption and message to null will restart the application (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.
- Communication error: the client failed to contact the server, or the server returned an invalid response.
- 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 Constructor Description CustomizedSystemMessages()
-
Method Summary
All Methods Modifier and Type Method Description void
setCookiesDisabledCaption(String cookiesDisabledCaption)
Sets the caption to show in an "cookies disabled" notification.
void
setCookiesDisabledMessage(String cookiesDisabledMessage)
Sets the message to show in a "cookies disabled" notification.
void
setCookiesDisabledNotificationEnabled(boolean cookiesDisabledNotificationEnabled)
Sets whether a "cookies disabled" notification should be shown to the end user.
void
setCookiesDisabledURL(String cookiesDisabledURL)
Sets the URL the user will be redirected to after dismissing a "cookies disabled" message.
void
setInternalErrorCaption(String internalErrorCaption)
Sets the caption to show in an "internal error" notification.
void
setInternalErrorMessage(String internalErrorMessage)
Sets the message to show in an "internal error" notification.
void
setInternalErrorNotificationEnabled(boolean internalErrorNotificationEnabled)
Sets whether an "internal error" notification should be shown to the end user.
void
setInternalErrorURL(String internalErrorURL)
Sets the URL the user will be redirected to after dismissing an "internal error" message.
void
setSessionExpiredCaption(String sessionExpiredCaption)
Sets the caption to show in a "session expired" notification.
void
setSessionExpiredMessage(String sessionExpiredMessage)
Sets the message to show in a "session expired" notification.
void
setSessionExpiredNotificationEnabled(boolean sessionExpiredNotificationEnabled)
Sets whether a "session expired" notification should be shown to the end user.
void
setSessionExpiredURL(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
-
-
-
-
Method Detail
-
setSessionExpiredURL
public void setSessionExpiredURL(String sessionExpiredURL)
Sets the URL the user will be redirected to after dismissing a "session expired" message.
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 by
SystemMessages.getSessionExpiredURL()
.Parameters:
sessionExpiredNotificationEnabled
-true
to show the notification to the end user,false
to redirect directly
-
setSessionExpiredCaption
public void setSessionExpiredCaption(String sessionExpiredCaption)
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 ornull
to show no caption.
-
setSessionExpiredMessage
public void setSessionExpiredMessage(String sessionExpiredMessage)
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 ornull
to show no message.
-
setInternalErrorURL
public void setInternalErrorURL(String internalErrorURL)
Sets the URL the user will be redirected to after dismissing an "internal error" message.
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 by
SystemMessages.getInternalErrorURL()
.Parameters:
internalErrorNotificationEnabled
-true
to show the notification to the end user,false
to redirect directly
-
setInternalErrorCaption
public void setInternalErrorCaption(String internalErrorCaption)
Sets the caption to show in an "internal error" notification.
Parameters:
internalErrorCaption
- The caption to show ornull
to show no caption.
-
setInternalErrorMessage
public void setInternalErrorMessage(String internalErrorMessage)
Sets the message to show in an "internal error" notification.
Parameters:
internalErrorMessage
- The message to show ornull
to show no message.
-
setCookiesDisabledURL
public void setCookiesDisabledURL(String cookiesDisabledURL)
Sets the URL the user will be redirected to after dismissing a "cookies disabled" message.
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 by
SystemMessages.getCookiesDisabledURL()
.Parameters:
cookiesDisabledNotificationEnabled
-true
to show the notification to the end user,false
to redirect directly
-
setCookiesDisabledCaption
public void setCookiesDisabledCaption(String cookiesDisabledCaption)
Sets the caption to show in an "cookies disabled" notification.
Parameters:
cookiesDisabledCaption
- The caption to show ornull
to show no caption.
-
setCookiesDisabledMessage
public void setCookiesDisabledMessage(String cookiesDisabledMessage)
Sets the message to show in a "cookies disabled" notification.
Parameters:
cookiesDisabledMessage
- The message to show ornull
to show no message.
-
-