]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #2570 / Sampler - Check dates for invalid values
authorArtur Signell <artur.signell@itmill.com>
Tue, 10 Feb 2009 10:49:57 +0000 (10:49 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 10 Feb 2009 10:49:57 +0000 (10:49 +0000)
svn changeset:6777/svn branch:trunk

src/com/itmill/toolkit/demo/sampler/features/dates/DatePopupExample.java

index 46c016306830b3bc4f68fdedb038ab6d83b96501..44592dd535e70395224a91e9c7b949ca84d33ca7 100644 (file)
@@ -1,6 +1,7 @@
 package com.itmill.toolkit.demo.sampler.features.dates;\r
 \r
 import java.text.DateFormat;\r
+import java.util.Date;\r
 \r
 import com.itmill.toolkit.data.Property;\r
 import com.itmill.toolkit.data.Property.ValueChangeEvent;\r
@@ -33,8 +34,13 @@ public class DatePopupExample extends VerticalLayout implements
     public void valueChange(ValueChangeEvent event) {\r
         // Get the new value and format it to the current locale\r
         DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT);\r
-        String dateOut = dateFormatter.format(event.getProperty().getValue());\r
-        // Show notification\r
-        getWindow().showNotification("Starting date: " + dateOut);\r
+        Object value = event.getProperty().getValue();\r
+        if (value == null || !(value instanceof Date)) {\r
+            getWindow().showNotification("Invalid date entered");\r
+        } else {\r
+            String dateOut = dateFormatter.format(value);\r
+            // Show notification\r
+            getWindow().showNotification("Starting date: " + dateOut);\r
+        }\r
     }\r
 }\r