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.

CustomizedSystemMessages.java 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. /**
  18. * Contains the system messages used to notify the user about various critical
  19. * situations that can occur.
  20. * <p>
  21. * Vaadin gets the SystemMessages from your application by calling a static
  22. * getSystemMessages() method. By default the Application.getSystemMessages() is
  23. * used. You can customize this by defining a static
  24. * MyApplication.getSystemMessages() and returning CustomizedSystemMessages.
  25. * Note that getSystemMessages() is static - changing the system messages will
  26. * by default change the message for all users of the application.
  27. * </p>
  28. * <p>
  29. * The default behavior is to show a notification, and restart the application
  30. * if the user clicks the message. <br/>
  31. * Instead of restarting the application, you can set a specific URL that the
  32. * user is taken to.<br/>
  33. * Setting both caption and message to null will restart the application (or go
  34. * to the specified URL) without displaying a notification.
  35. * set*NotificationEnabled(false) will achieve the same thing.
  36. * </p>
  37. * <p>
  38. * The situations are:
  39. * <li>Session expired: the user session has expired, usually due to inactivity.
  40. * </li>
  41. * <li>Authentication error: the client received a 401 (Unauthorized) response
  42. * from the server.</li>
  43. * <li>Communication error: the client failed to contact the server, or the
  44. * server returned an invalid response.</li>
  45. * <li>Internal error: unhandled critical server error (e.g out of memory,
  46. * database crash)
  47. * <li>Cookies disabled: the browser does not support cookies</li>
  48. * </p>
  49. */
  50. public class CustomizedSystemMessages extends SystemMessages {
  51. /**
  52. * Sets the URL to go to when the session has expired.
  53. *
  54. * @param sessionExpiredURL
  55. * the URL to go to, or null to reload current
  56. */
  57. public void setSessionExpiredURL(String sessionExpiredURL) {
  58. this.sessionExpiredURL = sessionExpiredURL;
  59. }
  60. /**
  61. * Enables or disables the notification. If disabled, the set URL (or
  62. * current) is loaded directly when next transaction between server and
  63. * client happens.
  64. *
  65. * @param sessionExpiredNotificationEnabled
  66. * true = enabled, false = disabled
  67. */
  68. public void setSessionExpiredNotificationEnabled(
  69. boolean sessionExpiredNotificationEnabled) {
  70. this.sessionExpiredNotificationEnabled = sessionExpiredNotificationEnabled;
  71. }
  72. /**
  73. * Sets the caption of the notification. Set to null for no caption. If both
  74. * caption and message are null, client automatically forwards to
  75. * sessionExpiredUrl after timeout timer expires. Timer uses value read from
  76. * HTTPSession.getMaxInactiveInterval()
  77. *
  78. * @param sessionExpiredCaption
  79. * the caption
  80. */
  81. public void setSessionExpiredCaption(String sessionExpiredCaption) {
  82. this.sessionExpiredCaption = sessionExpiredCaption;
  83. }
  84. /**
  85. * Sets the message of the notification. Set to null for no message. If both
  86. * caption and message are null, client automatically forwards to
  87. * sessionExpiredUrl after timeout timer expires. Timer uses value read from
  88. * HTTPSession.getMaxInactiveInterval()
  89. *
  90. * @param sessionExpiredMessage
  91. * the message
  92. */
  93. public void setSessionExpiredMessage(String sessionExpiredMessage) {
  94. this.sessionExpiredMessage = sessionExpiredMessage;
  95. }
  96. /**
  97. * Sets the URL to go to when there is a authentication error.
  98. *
  99. * @param authenticationErrorURL
  100. * the URL to go to, or null to reload current
  101. */
  102. public void setAuthenticationErrorURL(String authenticationErrorURL) {
  103. this.authenticationErrorURL = authenticationErrorURL;
  104. }
  105. /**
  106. * Enables or disables the notification. If disabled, the set URL (or
  107. * current) is loaded directly.
  108. *
  109. * @param authenticationErrorNotificationEnabled
  110. * true = enabled, false = disabled
  111. */
  112. public void setAuthenticationErrorNotificationEnabled(
  113. boolean authenticationErrorNotificationEnabled) {
  114. this.authenticationErrorNotificationEnabled = authenticationErrorNotificationEnabled;
  115. }
  116. /**
  117. * Sets the caption of the notification. Set to null for no caption. If both
  118. * caption and message is null, the notification is disabled;
  119. *
  120. * @param authenticationErrorCaption
  121. * the caption
  122. */
  123. public void setAuthenticationErrorCaption(
  124. String authenticationErrorCaption) {
  125. this.authenticationErrorCaption = authenticationErrorCaption;
  126. }
  127. /**
  128. * Sets the message of the notification. Set to null for no message. If both
  129. * caption and message is null, the notification is disabled;
  130. *
  131. * @param authenticationErrorMessage
  132. * the message
  133. */
  134. public void setAuthenticationErrorMessage(
  135. String authenticationErrorMessage) {
  136. this.authenticationErrorMessage = authenticationErrorMessage;
  137. }
  138. /**
  139. * Sets the URL to go to when there is a communication error.
  140. *
  141. * @param communicationErrorURL
  142. * the URL to go to, or null to reload current
  143. */
  144. public void setCommunicationErrorURL(String communicationErrorURL) {
  145. this.communicationErrorURL = communicationErrorURL;
  146. }
  147. /**
  148. * Enables or disables the notification. If disabled, the set URL (or
  149. * current) is loaded directly.
  150. *
  151. * @param communicationErrorNotificationEnabled
  152. * true = enabled, false = disabled
  153. */
  154. public void setCommunicationErrorNotificationEnabled(
  155. boolean communicationErrorNotificationEnabled) {
  156. this.communicationErrorNotificationEnabled = communicationErrorNotificationEnabled;
  157. }
  158. /**
  159. * Sets the caption of the notification. Set to null for no caption. If both
  160. * caption and message is null, the notification is disabled;
  161. *
  162. * @param communicationErrorCaption
  163. * the caption
  164. */
  165. public void setCommunicationErrorCaption(String communicationErrorCaption) {
  166. this.communicationErrorCaption = communicationErrorCaption;
  167. }
  168. /**
  169. * Sets the message of the notification. Set to null for no message. If both
  170. * caption and message is null, the notification is disabled;
  171. *
  172. * @param communicationErrorMessage
  173. * the message
  174. */
  175. public void setCommunicationErrorMessage(String communicationErrorMessage) {
  176. this.communicationErrorMessage = communicationErrorMessage;
  177. }
  178. /**
  179. * Sets the URL to go to when an internal error occurs.
  180. *
  181. * @param internalErrorURL
  182. * the URL to go to, or null to reload current
  183. */
  184. public void setInternalErrorURL(String internalErrorURL) {
  185. this.internalErrorURL = internalErrorURL;
  186. }
  187. /**
  188. * Enables or disables the notification. If disabled, the set URL (or
  189. * current) is loaded directly.
  190. *
  191. * @param internalErrorNotificationEnabled
  192. * true = enabled, false = disabled
  193. */
  194. public void setInternalErrorNotificationEnabled(
  195. boolean internalErrorNotificationEnabled) {
  196. this.internalErrorNotificationEnabled = internalErrorNotificationEnabled;
  197. }
  198. /**
  199. * Sets the caption of the notification. Set to null for no caption. If both
  200. * caption and message is null, the notification is disabled;
  201. *
  202. * @param internalErrorCaption
  203. * the caption
  204. */
  205. public void setInternalErrorCaption(String internalErrorCaption) {
  206. this.internalErrorCaption = internalErrorCaption;
  207. }
  208. /**
  209. * Sets the message of the notification. Set to null for no message. If both
  210. * caption and message is null, the notification is disabled;
  211. *
  212. * @param internalErrorMessage
  213. * the message
  214. */
  215. public void setInternalErrorMessage(String internalErrorMessage) {
  216. this.internalErrorMessage = internalErrorMessage;
  217. }
  218. /**
  219. * Sets the URL to redirect to when the browser has cookies disabled.
  220. *
  221. * @param cookiesDisabledURL
  222. * the URL to redirect to, or null to reload the current URL
  223. */
  224. public void setCookiesDisabledURL(String cookiesDisabledURL) {
  225. this.cookiesDisabledURL = cookiesDisabledURL;
  226. }
  227. /**
  228. * Enables or disables the notification for "cookies disabled" messages. If
  229. * disabled, the URL returned by {@link #getCookiesDisabledURL()} is loaded
  230. * directly.
  231. *
  232. * @param cookiesDisabledNotificationEnabled
  233. * true to enable "cookies disabled" messages, false otherwise
  234. */
  235. public void setCookiesDisabledNotificationEnabled(
  236. boolean cookiesDisabledNotificationEnabled) {
  237. this.cookiesDisabledNotificationEnabled = cookiesDisabledNotificationEnabled;
  238. }
  239. /**
  240. * Sets the caption of the "cookies disabled" notification. Set to null for
  241. * no caption. If both caption and message is null, the notification is
  242. * disabled.
  243. *
  244. * @param cookiesDisabledCaption
  245. * the caption for the "cookies disabled" notification
  246. */
  247. public void setCookiesDisabledCaption(String cookiesDisabledCaption) {
  248. this.cookiesDisabledCaption = cookiesDisabledCaption;
  249. }
  250. /**
  251. * Sets the message of the "cookies disabled" notification. Set to null for
  252. * no message. If both caption and message is null, the notification is
  253. * disabled.
  254. *
  255. * @param cookiesDisabledMessage
  256. * the message for the "cookies disabled" notification
  257. */
  258. public void setCookiesDisabledMessage(String cookiesDisabledMessage) {
  259. this.cookiesDisabledMessage = cookiesDisabledMessage;
  260. }
  261. }