]> source.dussan.org Git - vaadin-framework.git/commitdiff
Account for that converter can modify value (#8191) 25/325/2
authorArtur Signell <artur@vaadin.com>
Wed, 21 Nov 2012 15:06:57 +0000 (17:06 +0200)
committerVaadin Code Review <review@vaadin.com>
Thu, 22 Nov 2012 14:08:15 +0000 (14:08 +0000)
Change-Id: Iee81b46c985bbb37b98d23433e42d8d007c30d6a

server/src/com/vaadin/ui/AbstractField.java
uitest/src/com/vaadin/tests/converter/ConverterThatEnforcesAFormat.html [new file with mode: 0644]

index 5c4a3468bb5ada86c76969ea83fac1e2fe5d27c7..b52d733632221c7ed037a2d3d9976aa38d3130e4 100644 (file)
@@ -451,6 +451,16 @@ public abstract class AbstractField<T> extends AbstractComponent implements
             if (isReadOnly()) {
                 throw new Property.ReadOnlyException();
             }
+            try {
+                T doubleConvertedFieldValue = convertFromDataSource(convertToModel(newFieldValue));
+                if (!equals(newFieldValue, doubleConvertedFieldValue)) {
+                    newFieldValue = doubleConvertedFieldValue;
+                    repaintIsNotNeeded = false;
+                }
+            } catch (Throwable t) {
+                // Ignore exceptions in the conversion at this stage. Any
+                // conversion error will be handled later by validate().
+            }
 
             // Repaint is needed even when the client thinks that it knows the
             // new state if validity of the component may change
diff --git a/uitest/src/com/vaadin/tests/converter/ConverterThatEnforcesAFormat.html b/uitest/src/com/vaadin/tests/converter/ConverterThatEnforcesAFormat.html
new file mode 100644 (file)
index 0000000..455e56e
--- /dev/null
@@ -0,0 +1,62 @@
+<?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="http://arturwin.office.itmill.com:8888/" />
+<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>http://arturwin.office.itmill.com:8888/run/com.vaadin.tests.converter.ConverterThatEnforcesAFormat?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertValue</td>
+       <td>vaadin=runcomvaadintestsconverterConverterThatEnforcesAFormat::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VTextField[0]</td>
+       <td>50.000</td>
+</tr>
+<tr>
+       <td>type</td>
+       <td>vaadin=runcomvaadintestsconverterConverterThatEnforcesAFormat::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VTextField[0]</td>
+       <td>50.0202</td>
+</tr>
+<tr>
+       <td>assertValue</td>
+       <td>vaadin=runcomvaadintestsconverterConverterThatEnforcesAFormat::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VTextField[0]</td>
+       <td>50.020</td>
+</tr>
+<tr>
+       <td>type</td>
+       <td>vaadin=runcomvaadintestsconverterConverterThatEnforcesAFormat::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VTextField[0]</td>
+       <td>12</td>
+</tr>
+<tr>
+       <td>assertValue</td>
+       <td>vaadin=runcomvaadintestsconverterConverterThatEnforcesAFormat::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VTextField[0]</td>
+       <td>12.000</td>
+</tr>
+<tr>
+       <td>type</td>
+       <td>vaadin=runcomvaadintestsconverterConverterThatEnforcesAFormat::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VTextField[0]</td>
+       <td>abc</td>
+</tr>
+<tr>
+       <td>assertValue</td>
+       <td>vaadin=runcomvaadintestsconverterConverterThatEnforcesAFormat::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VTextField[0]</td>
+       <td>abc</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>vaadin=runcomvaadintestsconverterConverterThatEnforcesAFormat::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VTextField[0]</td>
+       <td>v-textfield-error</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>