summaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2012-11-01 15:10:40 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-20 11:25:37 +0000
commit1384f1eb2c973252da27d6e379d8b863d912b22e (patch)
treee2aad5da0e41b03dc9cb05e84e3b8e09ee9d7cbf /client/src
parent0e8647784782e132bed9ec93ed47ea876f753534 (diff)
downloadvaadin-framework-1384f1eb2c973252da27d6e379d8b863d912b22e.tar.gz
vaadin-framework-1384f1eb2c973252da27d6e379d8b863d912b22e.zip
When closeIdleUIs is true, close open UIs only after all UIs have been idle for longer than the session timeout
* Rename closeIdleUIs to closeIdleSessions, isIdleUICleanupEnabled to isCloseIdleSessions (#10252) * Close the whole session at the same time as well * Move UI lastUidlRequestTime to VaadinSession lastRequestTimestamp (#10253) * Rename VaadinSession lastRequestTime to lastRequestDuration, totalSessionTime to cumulativeRequestDuration (#10253) * Rename UI lastHeartbeatTime to lastHeartbeatTimestamp * Show "Session Expired" notification when a heartbeat fails because of this Change-Id: If3d4bd9add9995f435c29812eec00b3a3a92a6e6
Diffstat (limited to 'client/src')
-rw-r--r--client/src/com/vaadin/client/ApplicationConfiguration.java6
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java78
2 files changed, 46 insertions, 38 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java
index 4159b38211..1f35c408ae 100644
--- a/client/src/com/vaadin/client/ApplicationConfiguration.java
+++ b/client/src/com/vaadin/client/ApplicationConfiguration.java
@@ -199,6 +199,7 @@ public class ApplicationConfiguration implements EntryPoint {
private boolean standalone;
private ErrorMessage communicationError;
private ErrorMessage authorizationError;
+ private ErrorMessage sessionExpiredError;
private int heartbeatInterval;
private HashMap<Integer, String> unknownComponents;
@@ -314,6 +315,10 @@ public class ApplicationConfiguration implements EntryPoint {
return authorizationError;
}
+ public ErrorMessage getSessionExpiredError() {
+ return sessionExpiredError;
+ }
+
/**
* Reads the configuration values defined by the bootstrap javascript.
*/
@@ -353,6 +358,7 @@ public class ApplicationConfiguration implements EntryPoint {
communicationError = jsoConfiguration.getConfigError("comErrMsg");
authorizationError = jsoConfiguration.getConfigError("authErrMsg");
+ sessionExpiredError = jsoConfiguration.getConfigError("sessExpMsg");
// boostrap sets initPending to false if it has sent the browser details
if (jsoConfiguration.getConfigBoolean("initPending") == Boolean.FALSE) {
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 23906f0e02..9133e3dfc5 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -960,9 +960,7 @@ public class ApplicationConnection {
*/
protected void showCommunicationError(String details, int statusCode) {
VConsole.error("Communication error: " + details);
- ErrorMessage communicationError = configuration.getCommunicationError();
- showError(details, communicationError.getCaption(),
- communicationError.getMessage(), communicationError.getUrl());
+ showError(details, configuration.getCommunicationError());
}
/**
@@ -973,9 +971,31 @@ public class ApplicationConnection {
*/
protected void showAuthenticationError(String details) {
VConsole.error("Authentication error: " + details);
- ErrorMessage authorizationError = configuration.getAuthorizationError();
- showError(details, authorizationError.getCaption(),
- authorizationError.getMessage(), authorizationError.getUrl());
+ showError(details, configuration.getAuthorizationError());
+ }
+
+ /**
+ * Shows the session expiration notification.
+ *
+ * @param details
+ * Optional details for debugging.
+ */
+ protected void showSessionExpiredError(String details) {
+ VConsole.error("Session expired: " + details);
+ showError(details, configuration.getSessionExpiredError());
+ }
+
+ /**
+ * Shows an error notification.
+ *
+ * @param details
+ * Optional details for debugging.
+ * @param message
+ * An ErrorMessage describing the error.
+ */
+ protected void showError(String details, ErrorMessage message) {
+ showError(details, message.getCaption(), message.getMessage(),
+ message.getUrl());
}
/**
@@ -1002,9 +1022,11 @@ public class ApplicationConnection {
if (html.length() > 0) {
// Add error description
- html.append("<br/><p><I style=\"font-size:0.7em\">");
- html.append(details);
- html.append("</I></p>");
+ if (details != null) {
+ html.append("<p><i style=\"font-size:0.7em\">");
+ html.append(details);
+ html.append("</i></p>");
+ }
VNotification n = VNotification.createNotification(1000 * 60 * 45,
uIConnector.getWidget());
@@ -1442,32 +1464,11 @@ public class ApplicationConnection {
if (meta != null) {
if (meta.containsKey("appError")) {
ValueMap error = meta.getValueMap("appError");
- String html = "";
- if (error.containsKey("caption")
- && error.getString("caption") != null) {
- html += "<h1>" + error.getAsString("caption")
- + "</h1>";
- }
- if (error.containsKey("message")
- && error.getString("message") != null) {
- html += "<p>" + error.getAsString("message")
- + "</p>";
- }
- String url = null;
- if (error.containsKey("url")) {
- url = error.getString("url");
- }
- if (html.length() != 0) {
- /* 45 min */
- VNotification n = VNotification.createNotification(
- 1000 * 60 * 45, uIConnector.getWidget());
- n.addEventListener(new NotificationRedirect(url));
- n.show(html, VNotification.CENTERED_TOP,
- VNotification.STYLE_SYSTEM);
- } else {
- redirect(url);
- }
+ showError(null, error.getString("caption"),
+ error.getString("message"),
+ error.getString("url"));
+
applicationRunning = false;
}
if (validatingLayouts) {
@@ -3027,7 +3028,7 @@ public class ApplicationConnection {
* <p>
* Heartbeat requests are used to inform the server that the client-side is
* still alive. If the client page is closed or the connection lost, the
- * server will eventually close the inactive Root.
+ * server will eventually close the inactive UI.
* <p>
* <b>TODO</b>: Improved error handling, like in doUidlRequest().
*
@@ -3051,16 +3052,17 @@ public class ApplicationConnection {
// TODO Permit retry in some error situations
VConsole.log("Heartbeat response OK");
scheduleHeartbeat();
+ } else if (status == Response.SC_GONE) {
+ showSessionExpiredError(null);
} else {
- VConsole.error("Heartbeat request failed with status code "
+ VConsole.error("Failed sending heartbeat to server. Error code: "
+ status);
}
}
@Override
public void onError(Request request, Throwable exception) {
- VConsole.error("Heartbeat request resulted in exception");
- VConsole.error(exception);
+ VConsole.error("Exception sending heartbeat: " + exception);
}
};