You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SystemMessages.java 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.server;
  17. import java.io.Serializable;
  18. /**
  19. * Contains the system messages used to notify the user about various critical
  20. * situations that can occur.
  21. * <p>
  22. * Use {@link VaadinService#setSystemMessagesProvider(SystemMessagesProvider)}
  23. * to customize.
  24. * </p>
  25. * <p>
  26. * The defaults defined in this class are:
  27. * <ul>
  28. * <li><b>sessionExpiredURL</b> = null</li>
  29. * <li><b>sessionExpiredNotificationEnabled</b> = true</li>
  30. * <li><b>sessionExpiredCaption</b> = ""</li>
  31. * <li><b>sessionExpiredMessage</b> = "Take note of any unsaved data, and
  32. * <u>click here</u> to continue."</li>
  33. * <li><b>communicationErrorURL</b> = null</li>
  34. * <li><b>communicationErrorNotificationEnabled</b> = true</li>
  35. * <li><b>communicationErrorCaption</b> = "Communication problem"</li>
  36. * <li><b>communicationErrorMessage</b> = "Take note of any unsaved data, and
  37. * <u>click here</u> to continue."</li>
  38. * <li><b>internalErrorURL</b> = null</li>
  39. * <li><b>internalErrorNotificationEnabled</b> = true</li>
  40. * <li><b>internalErrorCaption</b> = "Internal error"</li>
  41. * <li><b>internalErrorMessage</b> = "Please notify the administrator.<br/>
  42. * Take note of any unsaved data, and <u>click here</u> to continue."</li>
  43. * <li><b>cookiesDisabledURL</b> = null</li>
  44. * <li><b>cookiesDisabledNotificationEnabled</b> = true</li>
  45. * <li><b>cookiesDisabledCaption</b> = "Cookies disabled"</li>
  46. * <li><b>cookiesDisabledMessage</b> = "This application requires cookies to
  47. * function.<br/>
  48. * Please enable cookies in your browser and <u>click here</u> to try
  49. * again.</li>
  50. * </ul>
  51. * </p>
  52. *
  53. */
  54. public class SystemMessages implements Serializable {
  55. protected String sessionExpiredURL = null;
  56. protected boolean sessionExpiredNotificationEnabled = true;
  57. protected String sessionExpiredCaption = "Session Expired";
  58. protected String sessionExpiredMessage = "Take note of any unsaved data, and <u>click here</u> or press ESC key to continue.";
  59. protected String communicationErrorURL = null;
  60. protected boolean communicationErrorNotificationEnabled = true;
  61. protected String communicationErrorCaption = "Communication problem";
  62. protected String communicationErrorMessage = "Take note of any unsaved data, and <u>click here</u> or press ESC to continue.";
  63. protected String authenticationErrorURL = null;
  64. protected boolean authenticationErrorNotificationEnabled = true;
  65. protected String authenticationErrorCaption = "Authentication problem";
  66. protected String authenticationErrorMessage = "Take note of any unsaved data, and <u>click here</u> or press ESC to continue.";
  67. protected String internalErrorURL = null;
  68. protected boolean internalErrorNotificationEnabled = true;
  69. protected String internalErrorCaption = "Internal error";
  70. protected String internalErrorMessage = "Please notify the administrator.<br/>Take note of any unsaved data, and <u>click here</u> or press ESC to continue.";
  71. protected String cookiesDisabledURL = null;
  72. protected boolean cookiesDisabledNotificationEnabled = true;
  73. protected String cookiesDisabledCaption = "Cookies disabled";
  74. protected String cookiesDisabledMessage = "This application requires cookies to function.<br/>Please enable cookies in your browser and <u>click here</u> or press ESC to try again.";
  75. /**
  76. * Use {@link CustomizedSystemMessages} to customize
  77. */
  78. SystemMessages() {
  79. }
  80. /**
  81. * @return null to indicate that the application will be restarted after
  82. * session expired message has been shown.
  83. */
  84. public String getSessionExpiredURL() {
  85. return sessionExpiredURL;
  86. }
  87. /**
  88. * @return true to show session expiration message.
  89. */
  90. public boolean isSessionExpiredNotificationEnabled() {
  91. return sessionExpiredNotificationEnabled;
  92. }
  93. /**
  94. * @return "" to show no caption.
  95. */
  96. public String getSessionExpiredCaption() {
  97. return (sessionExpiredNotificationEnabled ? sessionExpiredCaption
  98. : null);
  99. }
  100. /**
  101. * @return "Take note of any unsaved data, and <u>click here</u> to
  102. * continue."
  103. */
  104. public String getSessionExpiredMessage() {
  105. return (sessionExpiredNotificationEnabled ? sessionExpiredMessage
  106. : null);
  107. }
  108. /**
  109. * @return null to reload the application after communication error message.
  110. */
  111. public String getCommunicationErrorURL() {
  112. return communicationErrorURL;
  113. }
  114. /**
  115. * @return true to show the communication error message.
  116. */
  117. public boolean isCommunicationErrorNotificationEnabled() {
  118. return communicationErrorNotificationEnabled;
  119. }
  120. /**
  121. * @return "Communication problem"
  122. */
  123. public String getCommunicationErrorCaption() {
  124. return (communicationErrorNotificationEnabled
  125. ? communicationErrorCaption
  126. : null);
  127. }
  128. /**
  129. * @return "Take note of any unsaved data, and <u>click here</u> to
  130. * continue."
  131. */
  132. public String getCommunicationErrorMessage() {
  133. return (communicationErrorNotificationEnabled
  134. ? communicationErrorMessage
  135. : null);
  136. }
  137. /**
  138. * @return null to reload the application after authentication error
  139. * message.
  140. */
  141. public String getAuthenticationErrorURL() {
  142. return authenticationErrorURL;
  143. }
  144. /**
  145. * @return true to show the authentication error message.
  146. */
  147. public boolean isAuthenticationErrorNotificationEnabled() {
  148. return authenticationErrorNotificationEnabled;
  149. }
  150. /**
  151. * @return "Authentication problem"
  152. */
  153. public String getAuthenticationErrorCaption() {
  154. return (authenticationErrorNotificationEnabled
  155. ? authenticationErrorCaption
  156. : null);
  157. }
  158. /**
  159. * @return "Take note of any unsaved data, and <u>click here</u> to
  160. * continue."
  161. */
  162. public String getAuthenticationErrorMessage() {
  163. return (authenticationErrorNotificationEnabled
  164. ? authenticationErrorMessage
  165. : null);
  166. }
  167. /**
  168. * @return null to reload the current URL after internal error message has
  169. * been shown.
  170. */
  171. public String getInternalErrorURL() {
  172. return internalErrorURL;
  173. }
  174. /**
  175. * @return true to enable showing of internal error message.
  176. */
  177. public boolean isInternalErrorNotificationEnabled() {
  178. return internalErrorNotificationEnabled;
  179. }
  180. /**
  181. * @return "Internal error"
  182. */
  183. public String getInternalErrorCaption() {
  184. return (internalErrorNotificationEnabled ? internalErrorCaption : null);
  185. }
  186. /**
  187. * @return "Please notify the administrator.<br/>
  188. * Take note of any unsaved data, and <u>click here</u> to
  189. * continue."
  190. */
  191. public String getInternalErrorMessage() {
  192. return (internalErrorNotificationEnabled ? internalErrorMessage : null);
  193. }
  194. /**
  195. * Returns the URL the user should be redirected to after dismissing the
  196. * "you have to enable your cookies" message. Typically null.
  197. *
  198. * @return A URL the user should be redirected to after dismissing the
  199. * message or null to reload the current URL.
  200. */
  201. public String getCookiesDisabledURL() {
  202. return cookiesDisabledURL;
  203. }
  204. /**
  205. * Determines if "cookies disabled" messages should be shown to the end user
  206. * or not. If the notification is disabled the user will be immediately
  207. * redirected to the URL returned by {@link #getCookiesDisabledURL()}.
  208. *
  209. * @return true to show "cookies disabled" messages to the end user, false
  210. * to redirect to the given URL directly
  211. */
  212. public boolean isCookiesDisabledNotificationEnabled() {
  213. return cookiesDisabledNotificationEnabled;
  214. }
  215. /**
  216. * Returns the caption of the message shown to the user when cookies are
  217. * disabled in the browser.
  218. *
  219. * @return The caption of the "cookies disabled" message
  220. */
  221. public String getCookiesDisabledCaption() {
  222. return (cookiesDisabledNotificationEnabled ? cookiesDisabledCaption
  223. : null);
  224. }
  225. /**
  226. * Returns the message shown to the user when cookies are disabled in the
  227. * browser.
  228. *
  229. * @return The "cookies disabled" message
  230. */
  231. public String getCookiesDisabledMessage() {
  232. return (cookiesDisabledNotificationEnabled ? cookiesDisabledMessage
  233. : null);
  234. }
  235. }