|
|
|
|
|
|
|
|
import com.google.gwt.user.client.ui.HasWidgets; |
|
|
import com.google.gwt.user.client.ui.HasWidgets; |
|
|
import com.google.gwt.user.client.ui.Widget; |
|
|
import com.google.gwt.user.client.ui.Widget; |
|
|
import com.vaadin.client.ApplicationConfiguration.ErrorMessage; |
|
|
import com.vaadin.client.ApplicationConfiguration.ErrorMessage; |
|
|
|
|
|
import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; |
|
|
import com.vaadin.client.ResourceLoader.ResourceLoadEvent; |
|
|
import com.vaadin.client.ResourceLoader.ResourceLoadEvent; |
|
|
import com.vaadin.client.ResourceLoader.ResourceLoadListener; |
|
|
import com.vaadin.client.ResourceLoader.ResourceLoadListener; |
|
|
import com.vaadin.client.communication.HasJavaScriptConnectorHelper; |
|
|
import com.vaadin.client.communication.HasJavaScriptConnectorHelper; |
|
|
|
|
|
|
|
|
RequestCallback requestCallback = new RequestCallback() { |
|
|
RequestCallback requestCallback = new RequestCallback() { |
|
|
@Override |
|
|
@Override |
|
|
public void onError(Request request, Throwable exception) { |
|
|
public void onError(Request request, Throwable exception) { |
|
|
handleCommunicationError(exception.getMessage(), -1); |
|
|
|
|
|
|
|
|
handleError(exception.getMessage(), -1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void handleCommunicationError(String details, int statusCode) { |
|
|
|
|
|
if (!handleErrorInDelegate(details, statusCode)) { |
|
|
|
|
|
showCommunicationError(details, statusCode); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void handleError(String details, int statusCode) { |
|
|
|
|
|
handleCommunicationError(details, statusCode); |
|
|
endRequest(); |
|
|
endRequest(); |
|
|
|
|
|
|
|
|
// Consider application not running any more and prevent all |
|
|
// Consider application not running any more and prevent all |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}).schedule(100); |
|
|
}).schedule(100); |
|
|
} else { |
|
|
} else { |
|
|
handleCommunicationError( |
|
|
|
|
|
|
|
|
handleError( |
|
|
"Invalid status code 0 (server down?)", |
|
|
"Invalid status code 0 (server down?)", |
|
|
statusCode); |
|
|
statusCode); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} else if ((statusCode / 100) == 5) { |
|
|
} else if ((statusCode / 100) == 5) { |
|
|
// Something's wrong on the server, there's nothing the |
|
|
// Something's wrong on the server, there's nothing the |
|
|
// client can do except maybe try again. |
|
|
// client can do except maybe try again. |
|
|
handleCommunicationError("Server error. Error code: " |
|
|
|
|
|
|
|
|
handleError("Server error. Error code: " |
|
|
+ statusCode, statusCode); |
|
|
+ statusCode, statusCode); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private boolean handleErrorInDelegate(String details, int statusCode) { |
|
|
|
|
|
if (communicationErrorDelegate == null) { |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
private void handleCommunicationError(String details, int statusCode) { |
|
|
|
|
|
boolean handled = false; |
|
|
|
|
|
if (communicationErrorDelegate != null) { |
|
|
|
|
|
handled = communicationErrorDelegate.onError(details, statusCode); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return communicationErrorDelegate.onError(details, statusCode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!handled) { |
|
|
|
|
|
showCommunicationError(details, statusCode); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
push.init(this, pushState, new CommunicationErrorHandler() { |
|
|
push.init(this, pushState, new CommunicationErrorHandler() { |
|
|
@Override |
|
|
@Override |
|
|
public boolean onError(String details, int statusCode) { |
|
|
public boolean onError(String details, int statusCode) { |
|
|
showCommunicationError(details, statusCode); |
|
|
|
|
|
|
|
|
handleCommunicationError(details,statusCode); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |