From b7ea2100b1dd97e61bbf303f598d5b2119b369e0 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 10 Feb 2009 10:49:57 +0000 Subject: [PATCH] Fix for #2570 / Sampler - Check dates for invalid values svn changeset:6777/svn branch:trunk --- .../sampler/features/dates/DatePopupExample.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopupExample.java b/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopupExample.java index 46c0163068..44592dd535 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopupExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopupExample.java @@ -1,6 +1,7 @@ package com.itmill.toolkit.demo.sampler.features.dates; import java.text.DateFormat; +import java.util.Date; import com.itmill.toolkit.data.Property; import com.itmill.toolkit.data.Property.ValueChangeEvent; @@ -33,8 +34,13 @@ public class DatePopupExample extends VerticalLayout implements public void valueChange(ValueChangeEvent event) { // Get the new value and format it to the current locale DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT); - String dateOut = dateFormatter.format(event.getProperty().getValue()); - // Show notification - getWindow().showNotification("Starting date: " + dateOut); + Object value = event.getProperty().getValue(); + if (value == null || !(value instanceof Date)) { + getWindow().showNotification("Invalid date entered"); + } else { + String dateOut = dateFormatter.format(value); + // Show notification + getWindow().showNotification("Starting date: " + dateOut); + } } } -- 2.39.5