From: Artur Signell Date: Tue, 10 Feb 2009 10:49:57 +0000 (+0000) Subject: Fix for #2570 / Sampler - Check dates for invalid values X-Git-Tag: 6.7.0.beta1~3182 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b7ea2100b1dd97e61bbf303f598d5b2119b369e0;p=vaadin-framework.git Fix for #2570 / Sampler - Check dates for invalid values svn changeset:6777/svn branch:trunk --- 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); + } } }