How to use a CustomApplicationConnection ?

Hi
I am searching for a way to handle
CommunicationErrors and SessionExpiredErrors with custom behavier.

So i override the SystemMessages

[code]
getService().setSystemMessagesProvider(new SystemMessagesProvider() {

@Override
public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo) {
{ CustomizedSystemMessages messages = new CustomizedSystemMessages();
messages.setSessionExpiredNotificationEnabled(false);
messages.setSessionExpiredURL(“”);
messages.setCommunicationErrorNotificationEnabled(false);
messages.setCommunicationErrorURL(“”);
return messages;
} } })
[/code]in my CustomerServlet class and add a CustomizedSystemMessages

now i want to extend the ApplicationConnection Class to add my custom behavier to the showCommunicationError Method

public class CustomApplicationConnection extends ApplicationConnection {
@Override
protected void showCommunicationError(String details, int statusCode) {
super.showCommunicationError(details, statusCode);
System.out.println("Do something here");
}
...

}

But i cant figure out where to set the new CustomApplicationConnection on Java side.
Is there only the way by replacing the class in the UIWidgetSet.gwt.xml like this:

<replace-with class="com.myproject.gwt.client.CustomerApplicationConnection> <when-type-is class="com.vaadin.terminal.gwt.client.ApplicationConnection"/> </replace-with> Or is there a better way to accomplish this goal ?

Yes, that’s right - client side classes cannot be “dynamically” replaced using any server-side API as they need to be compiled to Javascript first.