diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-09-26 11:18:09 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-09-26 11:18:09 +0200 |
commit | 580559c65d60a29f3628eac616a1b4bbc4da708e (patch) | |
tree | dc18028c5378ba149500c56a3fe374cc7e85ad2a /vaadin-app | |
parent | bfdc9b4bab98a06dd530204e45970370ce104871 (diff) | |
download | skeletons-580559c65d60a29f3628eac616a1b4bbc4da708e.zip skeletons-580559c65d60a29f3628eac616a1b4bbc4da708e.tar.gz |
vaadim-app: add uncaught exceptions handler
Diffstat (limited to 'vaadin-app')
-rw-r--r-- | vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java index c516e55..1185f65 100644 --- a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java +++ b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java @@ -4,6 +4,7 @@ import java.util.Date; import com.vaadin.Application; import com.vaadin.terminal.UserError; +import com.vaadin.terminal.Terminal; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.util.ObjectProperty; @@ -70,6 +71,15 @@ class MainLayout extends VerticalLayout { event.getButton().setComponentError( new UserError("Stop pressing this button !!") ); } })); + /// + Button exceptionButton = new Button("throw an exception"); + addComponent(exceptionButton ); + exceptionButton.addListener( new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + throw new RuntimeException("Wahou !! : exception"); + } + }); // Button nextButton = new Button("next layout"); nextButton.setDescription("Go to next layout"); @@ -85,14 +95,23 @@ class MainLayout extends VerticalLayout { } public class HelloWorldApp extends Application { + private static final long serialVersionUID = 1L; - private static final long serialVersionUID = 1L; - - @Override - public void init() { + @Override + public void init() { final Window mainWindow = new Window("Hello World Application"); mainWindow.setContent( new MainLayout() ); setMainWindow(mainWindow); setLogoutURL("http://asynk.ch"); - } + } + + @Override + public void terminalError(Terminal.ErrorEvent event) { + // Call the default implementation. + super.terminalError(event); + // Some custom behaviour. + if (getMainWindow() != null) { + getMainWindow().showNotification("An unchecked exception occured!", event.getThrowable().toString(), Window.Notification.TYPE_ERROR_MESSAGE); + } + } } |