Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*
  2. * Copyright 2000-2014 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> =
  32. * "Take note of any unsaved data, and <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> =
  37. * "Take note of any unsaved data, and <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 again.</li>
  49. * </ul>
  50. * </p>
  51. *
  52. */
  53. public class SystemMessages implements Serializable {
  54. protected String sessionExpiredURL = null;
  55. protected boolean sessionExpiredNotificationEnabled = true;
  56. protected String sessionExpiredCaption = "Session Expired";
  57. protected String sessionExpiredMessage = "Take note of any unsaved data, and <u>click here</u> or press ESC key to continue.";
  58. protected String communicationErrorURL = null;
  59. protected boolean communicationErrorNotificationEnabled = true;
  60. protected String communicationErrorCaption = "Communication problem";
  61. protected String communicationErrorMessage = "Take note of any unsaved data, and <u>click here</u> or press ESC to continue.";
  62. protected String authenticationErrorURL = null;
  63. protected boolean authenticationErrorNotificationEnabled = true;
  64. protected String authenticationErrorCaption = "Authentication problem";
  65. protected String authenticationErrorMessage = "Take note of any unsaved data, and <u>click here</u> or press ESC to continue.";
  66. protected String internalErrorURL = null;
  67. protected boolean internalErrorNotificationEnabled = true;
  68. protected String internalErrorCaption = "Internal error";
  69. protected String internalErrorMessage = "Please notify the administrator.<br/>Take note of any unsaved data, and <u>click here</u> or press ESC to continue.";
  70. protected String cookiesDisabledURL = null;
  71. protected boolean cookiesDisabledNotificationEnabled = true;
  72. protected String cookiesDisabledCaption = "Cookies disabled";
  73. 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.";
  74. /**
  75. * Use {@link CustomizedSystemMessages} to customize
  76. */
  77. SystemMessages() {
  78. }
  79. /**
  80. * @return null to indicate that the application will be restarted after
  81. * session expired message has been shown.
  82. */
  83. public String getSessionExpiredURL() {
  84. return sessionExpiredURL;
  85. }
  86. /**
  87. * @return true to show session expiration message.
  88. */
  89. public boolean isSessionExpiredNotificationEnabled() {
  90. return sessionExpiredNotificationEnabled;
  91. }
  92. /**
  93. * @return "" to show no caption.
  94. */
  95. public String getSessionExpiredCaption() {
  96. return (sessionExpiredNotificationEnabled ? sessionExpiredCaption
  97. : null);
  98. }
  99. /**
  100. * @return
  101. * "Take note of any unsaved data, and <u>click here</u> to continue."
  102. */
  103. public String getSessionExpiredMessage() {
  104. return (sessionExpiredNotificationEnabled ? sessionExpiredMessage
  105. : null);
  106. }
  107. /**
  108. * @return null to reload the application after communication error message.
  109. */
  110. public String getCommunicationErrorURL() {
  111. return communicationErrorURL;
  112. }
  113. /**
  114. * @return true to show the communication error message.
  115. */
  116. public boolean isCommunicationErrorNotificationEnabled() {
  117. return communicationErrorNotificationEnabled;
  118. }
  119. /**
  120. * @return "Communication problem"
  121. */
  122. public String getCommunicationErrorCaption() {
  123. return (communicationErrorNotificationEnabled ? communicationErrorCaption
  124. : null);
  125. }
  126. /**
  127. * @return
  128. * "Take note of any unsaved data, and <u>click here</u> to continue."
  129. */
  130. public String getCommunicationErrorMessage() {
  131. return (communicationErrorNotificationEnabled ? communicationErrorMessage
  132. : null);
  133. }
  134. /**
  135. * @return null to reload the application after authentication error
  136. * message.
  137. */
  138. public String getAuthenticationErrorURL() {
  139. return authenticationErrorURL;
  140. }
  141. /**
  142. * @return true to show the authentication error message.
  143. */
  144. public boolean isAuthenticationErrorNotificationEnabled() {
  145. return authenticationErrorNotificationEnabled;
  146. }
  147. /**
  148. * @return "Authentication problem"
  149. */
  150. public String getAuthenticationErrorCaption() {
  151. return (authenticationErrorNotificationEnabled ? authenticationErrorCaption
  152. : null);
  153. }
  154. /**
  155. * @return
  156. * "Take note of any unsaved data, and <u>click here</u> to continue."
  157. */
  158. public String getAuthenticationErrorMessage() {
  159. return (authenticationErrorNotificationEnabled ? authenticationErrorMessage
  160. : null);
  161. }
  162. /**
  163. * @return null to reload the current URL after internal error message has
  164. * been shown.
  165. */
  166. public String getInternalErrorURL() {
  167. return internalErrorURL;
  168. }
  169. /**
  170. * @return true to enable showing of internal error message.
  171. */
  172. public boolean isInternalErrorNotificationEnabled() {
  173. return internalErrorNotificationEnabled;
  174. }
  175. /**
  176. * @return "Internal error"
  177. */
  178. public String getInternalErrorCaption() {
  179. return (internalErrorNotificationEnabled ? internalErrorCaption : null);
  180. }
  181. /**
  182. * @return "Please notify the administrator.<br/>
  183. * Take note of any unsaved data, and <u>click here</u> to
  184. * continue."
  185. */
  186. public String getInternalErrorMessage() {
  187. return (internalErrorNotificationEnabled ? internalErrorMessage : null);
  188. }
  189. /**
  190. * Returns the URL the user should be redirected to after dismissing the
  191. * "you have to enable your cookies" message. Typically null.
  192. *
  193. * @return A URL the user should be redirected to after dismissing the
  194. * message or null to reload the current URL.
  195. */
  196. public String getCookiesDisabledURL() {
  197. return cookiesDisabledURL;
  198. }
  199. /**
  200. * Determines if "cookies disabled" messages should be shown to the end user
  201. * or not. If the notification is disabled the user will be immediately
  202. * redirected to the URL returned by {@link #getCookiesDisabledURL()}.
  203. *
  204. * @return true to show "cookies disabled" messages to the end user, false
  205. * to redirect to the given URL directly
  206. */
  207. public boolean isCookiesDisabledNotificationEnabled() {
  208. return cookiesDisabledNotificationEnabled;
  209. }
  210. /**
  211. * Returns the caption of the message shown to the user when cookies are
  212. * disabled in the browser.
  213. *
  214. * @return The caption of the "cookies disabled" message
  215. */
  216. public String getCookiesDisabledCaption() {
  217. return (cookiesDisabledNotificationEnabled ? cookiesDisabledCaption
  218. : null);
  219. }
  220. /**
  221. * Returns the message shown to the user when cookies are disabled in the
  222. * browser.
  223. *
  224. * @return The "cookies disabled" message
  225. */
  226. public String getCookiesDisabledMessage() {
  227. return (cookiesDisabledNotificationEnabled ? cookiesDisabledMessage
  228. : null);
  229. }
  230. }