summaryrefslogtreecommitdiffstats
path: root/vaadin-app
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-09-26 11:55:46 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-09-26 11:55:46 +0200
commitd5b6ca708810a938b56f57beaf102d6d7319b550 (patch)
tree1272a4bc8c62e5a7c57797efcdbd45167bf4dd80 /vaadin-app
parent580559c65d60a29f3628eac616a1b4bbc4da708e (diff)
downloadskeletons-d5b6ca708810a938b56f57beaf102d6d7319b550.zip
skeletons-d5b6ca708810a938b56f57beaf102d6d7319b550.tar.gz
vaadin-app: change component error message from application level uncaught exception handler
Diffstat (limited to 'vaadin-app')
-rw-r--r--vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java
index 1185f65..3dfe515 100644
--- a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java
+++ b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java
@@ -5,6 +5,12 @@ import java.util.Date;
import com.vaadin.Application;
import com.vaadin.terminal.UserError;
import com.vaadin.terminal.Terminal;
+import com.vaadin.terminal.SystemError;
+import com.vaadin.terminal.ErrorMessage;
+import com.vaadin.terminal.VariableOwner;
+import com.vaadin.terminal.URIHandler;
+import com.vaadin.terminal.ParameterHandler;
+import com.vaadin.terminal.gwt.server.ChangeVariablesErrorEvent;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.util.ObjectProperty;
@@ -16,6 +22,7 @@ import com.vaadin.ui.Label;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.TextField;
+import com.vaadin.ui.AbstractComponent;
class DataMappingLayout extends FormLayout {
@@ -108,7 +115,27 @@ public class HelloWorldApp extends Application {
@Override
public void terminalError(Terminal.ErrorEvent event) {
// Call the default implementation.
- super.terminalError(event);
+ //super.terminalError(event);
+ // http://dev.vaadin.com/browser/releases/6.6.6/src/com/vaadin/Application.java#L1190
+ final Throwable t = event.getThrowable();
+ Object owner = null;
+ if (event instanceof VariableOwner.ErrorEvent) {
+ owner = ((VariableOwner.ErrorEvent) event).getVariableOwner();
+ } else if (event instanceof URIHandler.ErrorEvent) {
+ owner = ((URIHandler.ErrorEvent) event).getURIHandler();
+ } else if (event instanceof ParameterHandler.ErrorEvent) {
+ owner = ((ParameterHandler.ErrorEvent) event).getParameterHandler();
+ } else if (event instanceof ChangeVariablesErrorEvent) {
+ owner = ((ChangeVariablesErrorEvent) event).getComponent();
+ }
+ if (owner instanceof AbstractComponent) {
+ if (t instanceof ErrorMessage) {
+ ((AbstractComponent) owner).setComponentError((ErrorMessage)t);
+ } else {
+ //((AbstractComponent) owner).setComponentError(new SystemError(t));
+ ((AbstractComponent) owner).setComponentError(new UserError("User Error!"));
+ }
+ }
// Some custom behaviour.
if (getMainWindow() != null) {
getMainWindow().showNotification("An unchecked exception occured!", event.getThrowable().toString(), Window.Notification.TYPE_ERROR_MESSAGE);