diff options
author | Artur Signell <artur@vaadin.com> | 2013-05-21 16:51:32 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-05-22 13:50:40 +0000 |
commit | 6bf83a428aa747f6b46d1d4c4ad2e279971d14e7 (patch) | |
tree | 2120465ccf24b83acf01ba6c829c4fe59866b74b /server/src/com/vaadin/ui/AbstractField.java | |
parent | 0b635061bb9b30e9f28d49fe9606eb3cab2fd3f1 (diff) | |
download | vaadin-framework-6bf83a428aa747f6b46d1d4c4ad2e279971d14e7.tar.gz vaadin-framework-6bf83a428aa747f6b46d1d4c4ad2e279971d14e7.zip |
Modified the logic in setPropertyDatasource which determines if a new converter is needed (#11863)
The previous logic had two flaws
* It allowed converter model type to be a sub type of the model type but not vice versa. Similarly for presentation type.
* If the user has set a converter it should be used and not be replaced unless it is absolutely sure that it cannot in any possible way handle conversion (e.g. converter from integer to double cannot handle string to list conversion). If there is a slight chance that it can handle conversion, let it be and let the user set another converter when needed.
Change-Id: I2e1c0b3aac90be63ddbc780195f8428398e28ada
Diffstat (limited to 'server/src/com/vaadin/ui/AbstractField.java')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractField.java | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index 3bca63a3b7..606bf5fb21 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -616,17 +616,14 @@ public abstract class AbstractField<T> extends AbstractComponent implements // Check if the current converter is compatible. if (newDataSource != null - && !ConverterUtil.canConverterHandle(getConverter(), getType(), - newDataSource.getType())) { - // Changing from e.g. Number -> Double should set a new converter, - // changing from Double -> Number can keep the old one (Property - // accepts Number) - - // Set a new converter if there is a new data source and - // there is no old converter or the old is incompatible. + && !ConverterUtil.canConverterPossiblyHandle(getConverter(), + getType(), newDataSource.getType())) { + // There is no converter set or there is no way the current + // converter can be compatible. setConverter(newDataSource.getType()); } - // Gets the value from source + // Gets the value from source. This requires that a valid converter has + // been set. try { if (dataSource != null) { T fieldValue = convertFromModel(getDataSourceValue()); |