/lib/session/

der'> cgit logo index : vaadin-framework.git
Vaadin 6, 7, 8 is a Java framework for modern Java web applications: https://github.com/vaadin/frameworkwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin/server/CustomizedSystemMessages.java
blob: 0a7f864f40d073cd0cf8d8cba97b775be58c0ad7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
/*
 * Copyright 2000-2014 Vaadin Ltd.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.vaadin.server;

import java.io.Serializable;

/**
 * Contains the system messages used to notify the user about various critical
 * situations that can occur.
 * <p>
 * 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.
 * </p>
 * <p>
 * The default behavior is to show a notification, and restart the application
 * the the user clicks the message. <br/>
 * Instead of restarting the application, you can set a specific URL that the
 * user is taken to.<br/>
 * 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.
 * </p>
 * <p>
 * The situations are:
 * <li>Session expired: the user session has expired, usually due to inactivity.
 * </li>
 * <li>Communication error: the client failed to contact the server, or the
 * server returned and invalid response.</li>
 * <li>Internal error: unhandled critical server error (e.g out of memory,
 * database crash)
 * </p>
 */

public class CustomizedSystemMessages extends SystemMessages implements
        Serializable {

    /**
     * Sets the URL to go to when the session has expired.
     * 
     * @param sessionExpiredURL
     *            the URL to go to, or null to reload current
     */
    public void setSessionExpiredURL(String sessionExpiredURL) {
        this.sessionExpiredURL = sessionExpiredURL;
    }

    /**
     * Enables or disables the notification. If disabled, the set URL (or
     * current) is loaded directly when next transaction between server and
     * client happens.
     * 
     * @param sessionExpiredNotificationEnabled
     *            true = enabled, false = disabled
     */
    public void setSessionExpiredNotificationEnabled(
            boolean sessionExpiredNotificationEnabled) {
        this.sessionExpiredNotificationEnabled = sessionExpiredNotificationEnabled;
    }

    /**
     * Sets the caption of the notification. Set to null for no caption. If both
     * caption and message are null, client automatically forwards to
     * sessionExpiredUrl after timeout timer expires. Timer uses value read from
     * HTTPSession.getMaxInactiveInterval()
     * 
     * @param sessionExpiredCaption
     *            the caption
     */
    public void setSessionExpiredCaption(String sessionExpiredCaption) {
        this.sessionExpiredCaption = sessionExpiredCaption;
    }

    /**
     * Sets the message of the notification. Set to null for no message. If both
     * caption and message are null, client automatically forwards to
     * sessionExpiredUrl after timeout timer expires. Timer uses value read from
     * HTTPSession.getMaxInactiveInterval()
     * 
     * @param sessionExpiredMessage
     *            the message
     */
    public void setSessionExpiredMessage(String sessionExpiredMessage) {
        this.sessionExpiredMessage = sessionExpiredMessage;
    }

    /**
     * Sets the URL to go to when there is a authentication error.
     * 
     * @param authenticationErrorURL
     *            the URL to go to, or null to reload current
     */
    public void setAuthenticationErrorURL(String authenticationErrorURL) {
        this.authenticationErrorURL = authenticationErrorURL;
    }

    /**
     * Enables or disables the notification. If disabled, the set URL (or
     * current) is loaded directly.
     * 
     * @param authenticationErrorNotificationEnabled
     *            true = enabled, false = disabled
     */
    public void setAuthenticationErrorNotificationEnabled(
            boolean authenticationErrorNotificationEnabled) {
        this.authenticationErrorNotificationEnabled = authenticationErrorNotificationEnabled;
    }

    /**
     * Sets the caption of the notification. Set to null for no caption. If both
     * caption and message is null, the notification is disabled;
     * 
     * @param authenticationErrorCaption
     *            the caption
     */
    public void setAuthenticationErrorCaption(String authenticationErrorCaption) {
        this.authenticationErrorCaption = authenticationErrorCaption;
    }

    /**
     * Sets the message of the notification. Set to null for no message. If both
     * caption and message is null, the notification is disabled;
     * 
     * @param authenticationErrorMessage
     *            the message
     */
    public void setAuthenticationErrorMessage(String authenticationErrorMessage) {
        this.authenticationErrorMessage = authenticationErrorMessage;
    }

    /**
     * Sets the URL to go to when there is a communication error.
     * 
     * @param communicationErrorURL
     *            the URL to go to, or null to reload current
     */
    public void setCommunicationErrorURL(String communicationErrorURL) {
        this.communicationErrorURL = communicationErrorURL;
    }

    /**
     * Enables or disables the notification. If disabled, the set URL (or
     * current) is loaded directly.
     * 
     * @param communicationErrorNotificationEnabled
     *            true = enabled, false = disabled
     */
    public void setCommunicationErrorNotificationEnabled(
            boolean communicationErrorNotificationEnabled) {
        this.communicationErrorNotificationEnabled = communicationErrorNotificationEnabled;
    }

    /**
     * Sets the caption of the notification. Set to null for no caption. If both
     * caption and message is null, the notification is disabled;
     * 
     * @param communicationErrorCaption
     *            the caption
     */
    public void setCommunicationErrorCaption(String communicationErrorCaption) {
        this.communicationErrorCaption = communicationErrorCaption;
    }

    /**
     * Sets the message of the notification. Set to null for no message. If both
     * caption and message is null, the notification is disabled;
     * 
     * @param communicationErrorMessage
     *            the message
     */
    public void setCommunicationErrorMessage(String communicationErrorMessage) {
        this.communicationErrorMessage = communicationErrorMessage;
    }

    /**
     * Sets the URL to go to when an internal error occurs.
     * 
     * @param internalErrorURL
     *            the URL to go to, or null to reload current
     */
    public void setInternalErrorURL(String internalErrorURL) {
        this.internalErrorURL = internalErrorURL;
    }

    /**
     * Enables or disables the notification. If disabled, the set URL (or
     * current) is loaded directly.
     * 
     * @param internalErrorNotificationEnabled
     *            true = enabled, false = disabled
     */
    public void setInternalErrorNotificationEnabled(
            boolean internalErrorNotificationEnabled) {
        this.internalErrorNotificationEnabled = internalErrorNotificationEnabled;
    }

    /**
     * Sets the caption of the notification. Set to null for no caption. If both
     * caption and message is null, the notification is disabled;
     * 
     * @param internalErrorCaption
     *            the caption
     */
    public void setInternalErrorCaption(String internalErrorCaption) {
        this.internalErrorCaption = internalErrorCaption;
    }

    /**
     * Sets the message of the notification. Set to null for no message. If both
     * caption and message is null, the notification is disabled;
     * 
     * @param internalErrorMessage
     *            the message
     */
    public void setInternalErrorMessage(String internalErrorMessage) {
        this.internalErrorMessage = internalErrorMessage;
    }

    /**
     * Sets the URL to redirect to when the browser has cookies disabled.
     * 
     * @param cookiesDisabledURL
     *            the URL to redirect to, or null to reload the current URL
     */
    public void setCookiesDisabledURL(String cookiesDisabledURL) {
        this.cookiesDisabledURL = cookiesDisabledURL;
    }

    /**
     * Enables or disables the notification for "cookies disabled" messages. If
     * disabled, the URL returned by {@link #getCookiesDisabledURL()} is loaded
     * directly.
     * 
     * @param cookiesDisabledNotificationEnabled
     *            true to enable "cookies disabled" messages, false otherwise
     */
    public void setCookiesDisabledNotificationEnabled(
            boolean cookiesDisabledNotificationEnabled) {
        this.cookiesDisabledNotificationEnabled = cookiesDisabledNotificationEnabled;
    }

    /**
     * Sets the caption of the "cookies disabled" notification. Set to null for
     * no caption. If both caption and message is null, the notification is
     * disabled.
     * 
     * @param cookiesDisabledCaption
     *            the caption for the "cookies disabled" notification
     */
    public void setCookiesDisabledCaption(String cookiesDisabledCaption) {
        this.cookiesDisabledCaption = cookiesDisabledCaption;
    }

    /**
     * Sets the message of the "cookies disabled" notification. Set to null for
     * no message. If both caption and message is null, the notification is
     * disabled.
     * 
     * @param cookiesDisabledMessage
     *            the message for the "cookies disabled" notification
     */
    public void setCookiesDisabledMessage(String cookiesDisabledMessage) {
        this.cookiesDisabledMessage = cookiesDisabledMessage;
    }

}