summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonatan Kronqvist <jonatan.kronqvist@itmill.com>2010-12-14 08:42:09 +0000
committerJonatan Kronqvist <jonatan.kronqvist@itmill.com>2010-12-14 08:42:09 +0000
commit4e247e537b129c1f17ee9976d1c3babe12b8cc9c (patch)
tree8049031342a54f4a455942ddd292b6f8940d9fc9
parente3c3944506169d92ba8d41596eee188bdbd0d5e3 (diff)
downloadvaadin-framework-4e247e537b129c1f17ee9976d1c3babe12b8cc9c.tar.gz
vaadin-framework-4e247e537b129c1f17ee9976d1c3babe12b8cc9c.zip
Fix for #5810
svn changeset:16482/svn branch:6.5
-rw-r--r--src/com/vaadin/ui/DateField.java3
-rw-r--r--tests/src/com/vaadin/tests/components/datefield/ValueThroughProperty.html47
-rw-r--r--tests/src/com/vaadin/tests/components/datefield/ValueThroughProperty.java72
3 files changed, 122 insertions, 0 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.datefield.ValueThroughProperty?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldValueThroughProperty::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupCalendar[0]#field</td>
+ <td>30,7</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldValueThroughProperty::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupCalendar[0]#field</td>
+ <td>asdf</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldValueThroughProperty::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[0]/domChild[1]</td>
+ <td>246,18</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldValueThroughProperty::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertValue</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldValueThroughProperty::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupCalendar[0]#field</td>
+ <td>12/14/10</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
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<Date>(null,
+ Date.class);
+
+ @Override
+ protected void setup() {
+ addComponent(new Label(
+ "Try to input an invalid value to the DateField, for example \"asdf\".<br />"
+ + "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.<br/>"
+ + "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;
+ }
+
+}