aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-11-21 17:06:57 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-22 14:08:15 +0000
commit66b1aa488099e8e79c3fb2fb1f0236c29f15f848 (patch)
tree8f9ccaeaf25c62d935de3575ecbeb61a46ca05e2
parent45fb000147cda84221c70c8f9da1a9d316d3c54f (diff)
downloadvaadin-framework-66b1aa488099e8e79c3fb2fb1f0236c29f15f848.tar.gz
vaadin-framework-66b1aa488099e8e79c3fb2fb1f0236c29f15f848.zip
Account for that converter can modify value (#8191)
Change-Id: Iee81b46c985bbb37b98d23433e42d8d007c30d6a
-rw-r--r--server/src/com/vaadin/ui/AbstractField.java10
-rw-r--r--uitest/src/com/vaadin/tests/converter/ConverterThatEnforcesAFormat.html62
2 files changed, 72 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java
index 5c4a3468bb..b52d733632 100644
--- a/server/src/com/vaadin/ui/AbstractField.java
+++ b/server/src/com/vaadin/ui/AbstractField.java
@@ -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
index 0000000000..455e56e647
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/converter/ConverterThatEnforcesAFormat.html
@@ -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>