ApplicationConnection communicationErrorDelegate

Hi

We use Vaadin 7 and we wanted to make use of communicationErrorDelegate. (Reason for this is to handle error 500 in a custom manner)

We tried two different approaches.

first approach: extend
This woked well for the error handling, (so when the error 500 arrived our implementation was in place). But the touchkit OfflineMode was not working anymore. It look like there was a problem with the ApplicationConnection (seems to be null when the offlineMode is hooked in).

package xx.clientportal.client;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.Location;
import com.vaadin.addon.touchkit.gwt.client.vcom.OfflineModeConnector;
import com.vaadin.client.ApplicationConnection;

public class CustomApplicationConnection extends ApplicationConnection {
    public CustomApplicationConnection() {
        super.setCommunicationErrorDelegate(new CustomOfflineModeConnector());
    }
    
}

class CustomOfflineModeConnector extends OfflineModeConnector{
    
    private static final long serialVersionUID = -1626385785071990584L;
    
    @Override
    public boolean onError(String details, int statusCode) {
        if (500 == statusCode) {
            Window.alert("handle 500");
            Location.replace("/go/somewhere");
            return true;
        }
        return super.onError(details, statusCode);
    }   
}

second approach : wrap
This did not work at all, we verified that the constructor of CustomApplicationConnection was called. But the CommunicationErrorHandler got never called.

package xx.clientportal.client;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.Location;
import com.vaadin.client.ApplicationConnection;

public class CustomApplicationConnection extends ApplicationConnection {

    @Override
    public void setCommunicationErrorDelegate(final CommunicationErrorHandler delegate) {

        super.setCommunicationErrorDelegate(

        new CommunicationErrorHandler() {

            @Override
            public boolean onError(String details, int statusCode) {
                if (500 == statusCode) {
Window.alert("handle 500");
                    Location.replace("/go/somewhere");
                    return true;
                }
                return delegate.onError(details, statusCode);
            }
        });
    }

}

in MyWidgetSet.gwt.xml we replaced the application connection with

<replace-with class="xx.clientportal.client.CustomApplicationConnection">
        <when-type-is class="com.vaadin.client.ApplicationConnection" />
    </replace-with>

Does anyone has an idea what we did wrong or what we missunderstood?

What next, the next approach we have in mind is to again customize the applicationConnection by extending it and then overwrite doUidlRequest and implement the whole RequestCallback. (But I don’t think this was the intention)