summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2013-05-22 12:09:00 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2013-05-22 12:09:00 +0300
commitebb92e621a3dee4253f3618a32edcd59ee51ef69 (patch)
treef103267328b2aadfc710feab54a5f28e79a010f7 /client
parent6a7683bedbdc745a6296a44a0328d61172181442 (diff)
downloadvaadin-framework-ebb92e621a3dee4253f3618a32edcd59ee51ef69.tar.gz
vaadin-framework-ebb92e621a3dee4253f3618a32edcd59ee51ef69.zip
Improve error message if vaadinPush.js failed to load (#11673)
Change-Id: I46a2622585ed69a1db4c6abf4aca4387387a0f97
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java8
-rw-r--r--client/src/com/vaadin/client/communication/AtmospherePushConnection.java31
-rw-r--r--client/src/com/vaadin/client/communication/PushConnection.java4
3 files changed, 32 insertions, 11 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 4141f9f2dc..087ee87262 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -3404,7 +3404,13 @@ public class ApplicationConnection {
public void setPushEnabled(boolean enabled) {
if (enabled && push == null) {
push = GWT.create(PushConnection.class);
- push.init(this);
+ push.init(this, new CommunicationErrorHandler() {
+ @Override
+ public boolean onError(String details, int statusCode) {
+ showCommunicationError(details, statusCode);
+ return true;
+ }
+ });
} else if (!enabled && push != null && push.isActive()) {
push.disconnect(new Command() {
@Override
diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
index ce3253ed50..997e84145c 100644
--- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
+++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
@@ -22,6 +22,7 @@ import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.user.client.Command;
import com.vaadin.client.ApplicationConnection;
+import com.vaadin.client.ApplicationConnection.CommunicationErrorHandler;
import com.vaadin.client.ResourceLoader;
import com.vaadin.client.ResourceLoader.ResourceLoadEvent;
import com.vaadin.client.ResourceLoader.ResourceLoadListener;
@@ -117,6 +118,8 @@ public class AtmospherePushConnection implements PushConnection {
private String transport;
+ private CommunicationErrorHandler errorHandler;
+
/**
* Keeps track of the disconnect confirmation command for cases where
* pending messages should be pushed before actually disconnecting.
@@ -134,8 +137,10 @@ public class AtmospherePushConnection implements PushConnection {
* .ApplicationConnection)
*/
@Override
- public void init(final ApplicationConnection connection) {
+ public void init(final ApplicationConnection connection,
+ CommunicationErrorHandler errorHandler) {
this.connection = connection;
+ this.errorHandler = errorHandler;
runWhenAtmosphereLoaded(new Command() {
@Override
@@ -433,22 +438,30 @@ public class AtmospherePushConnection implements PushConnection {
if (isAtmosphereLoaded()) {
command.execute();
} else {
- VConsole.log("Loading " + ApplicationConstants.VAADIN_PUSH_JS);
+ final String pushJs = ApplicationConstants.VAADIN_PUSH_JS;
+ VConsole.log("Loading " + pushJs);
ResourceLoader.get().loadScript(
- connection.getConfiguration().getVaadinDirUrl()
- + ApplicationConstants.VAADIN_PUSH_JS,
+ connection.getConfiguration().getVaadinDirUrl() + pushJs,
new ResourceLoadListener() {
@Override
public void onLoad(ResourceLoadEvent event) {
- VConsole.log(ApplicationConstants.VAADIN_PUSH_JS
- + " loaded");
- command.execute();
+ if (isAtmosphereLoaded()) {
+ VConsole.log(pushJs + " loaded");
+ command.execute();
+ } else {
+ // If bootstrap tried to load vaadinPush.js,
+ // ResourceLoader assumes it succeeded even if
+ // it failed (#11673)
+ onError(event);
+ }
}
@Override
public void onError(ResourceLoadEvent event) {
- VConsole.error(event.getResourceUrl()
- + " could not be loaded. Push will not work.");
+ errorHandler.onError(
+ event.getResourceUrl()
+ + " could not be loaded. Push will not work.",
+ 0);
}
});
}
diff --git a/client/src/com/vaadin/client/communication/PushConnection.java b/client/src/com/vaadin/client/communication/PushConnection.java
index 61656242bd..a4a3bbc0cc 100644
--- a/client/src/com/vaadin/client/communication/PushConnection.java
+++ b/client/src/com/vaadin/client/communication/PushConnection.java
@@ -18,6 +18,7 @@ package com.vaadin.client.communication;
import com.google.gwt.user.client.Command;
import com.vaadin.client.ApplicationConnection;
+import com.vaadin.client.ApplicationConnection.CommunicationErrorHandler;
/**
* Represents the client-side endpoint of a bidirectional ("push") communication
@@ -37,7 +38,8 @@ public interface PushConnection {
* @param connection
* The ApplicationConnection
*/
- public void init(ApplicationConnection connection);
+ public void init(ApplicationConnection connection,
+ CommunicationErrorHandler errorHandler);
/**
* Pushes a message to the server. Will throw an exception if the connection