From 4e247e537b129c1f17ee9976d1c3babe12b8cc9c Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Tue, 14 Dec 2010 08:42:09 +0000 Subject: Fix for #5810 svn changeset:16482/svn branch:6.5 --- src/com/vaadin/ui/DateField.java | 3 + .../components/datefield/ValueThroughProperty.html | 47 ++++++++++++++ .../components/datefield/ValueThroughProperty.java | 72 ++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 tests/src/com/vaadin/tests/components/datefield/ValueThroughProperty.html create mode 100644 tests/src/com/vaadin/tests/components/datefield/ValueThroughProperty.java diff --git a/src/com/vaadin/ui/DateField.java b/src/com/vaadin/ui/DateField.java index 0300315dd7..ac76ae7209 100644 --- a/src/com/vaadin/ui/DateField.java +++ b/src/com/vaadin/ui/DateField.java @@ -705,6 +705,9 @@ public class DateField extends AbstractField implements dateString = value.toString(); } + setComponentError(null); + parsingSucceeded = true; + super.valueChange(event); } diff --git a/tests/src/com/vaadin/tests/components/datefield/ValueThroughProperty.html b/tests/src/com/vaadin/tests/components/datefield/ValueThroughProperty.html new file mode 100644 index 0000000000..ce74f8941e --- /dev/null +++ b/tests/src/com/vaadin/tests/components/datefield/ValueThroughProperty.html @@ -0,0 +1,47 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.datefield.ValueThroughProperty?restartApplication
mouseClickvaadin=runcomvaadintestscomponentsdatefieldValueThroughProperty::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupCalendar[0]#field30,7
enterCharactervaadin=runcomvaadintestscomponentsdatefieldValueThroughProperty::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupCalendar[0]#fieldasdf
mouseClickvaadin=runcomvaadintestscomponentsdatefieldValueThroughProperty::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[0]/domChild[1]246,18
clickvaadin=runcomvaadintestscomponentsdatefieldValueThroughProperty::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
assertValuevaadin=runcomvaadintestscomponentsdatefieldValueThroughProperty::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupCalendar[0]#field12/14/10
+ + diff --git a/tests/src/com/vaadin/tests/components/datefield/ValueThroughProperty.java b/tests/src/com/vaadin/tests/components/datefield/ValueThroughProperty.java new file mode 100644 index 0000000000..e39e3ea963 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/datefield/ValueThroughProperty.java @@ -0,0 +1,72 @@ +package com.vaadin.tests.components.datefield; + +import java.util.Calendar; +import java.util.Date; + +import com.vaadin.data.Property; +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.DateField; +import com.vaadin.ui.Label; +import com.vaadin.ui.PopupDateField; + +public class ValueThroughProperty extends TestBase { + private final Property dateProperty = new ObjectProperty(null, + Date.class); + + @Override + protected void setup() { + addComponent(new Label( + "Try to input an invalid value to the DateField, for example \"asdf\".
" + + "Then try to set DateField's value using the first button. It sets the value " + + "correctly (as we can see from the Label) but the client-side is not updated.
" + + "Using second button updates value correctly on the client-side too.", + Label.CONTENT_XML)); + + final PopupDateField df = new PopupDateField(dateProperty); + df.setImmediate(true); + df.setResolution(DateField.RESOLUTION_DAY); + addComponent(df); + + Label valueLabel = new Label(df.getPropertyDataSource()); + valueLabel.setCaption("DateField's value"); + addComponent(valueLabel); + + final Calendar cal = Calendar.getInstance(); + cal.set(Calendar.YEAR, 2010); + cal.set(Calendar.MONTH, 11); + cal.set(Calendar.DAY_OF_MONTH, 14); + Button setDateButton1 = new Button( + "Set value to 12/14/10 using property", new ClickListener() { + public void buttonClick(ClickEvent event) { + dateProperty.setValue(cal.getTime()); + } + + }); + addComponent(setDateButton1); + + Button setDateButton2 = new Button( + "Set value to 12/14/10 using setValue", new ClickListener() { + public void buttonClick(ClickEvent event) { + df.setValue(cal.getTime()); + } + + }); + addComponent(setDateButton2); + } + + @Override + protected String getDescription() { + return "Setting a value through a property should update the" + + " client-side even if it contains an invalid value."; + } + + @Override + protected Integer getTicketNumber() { + return 5810; + } + +} -- cgit v1.2.3