summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/src/com/vaadin/ui/AbstractField.java17
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionError.java15
2 files changed, 24 insertions, 8 deletions
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java
index 6a52d6b849..b96e331889 100644
--- a/server/src/com/vaadin/ui/AbstractField.java
+++ b/server/src/com/vaadin/ui/AbstractField.java
@@ -783,15 +783,16 @@ public abstract class AbstractField<T> extends AbstractComponent implements
ConversionException e) {
String conversionError = getConversionError();
- if (dataSourceType != null) {
- conversionError = conversionError.replace("{0}",
- dataSourceType.getSimpleName());
- }
- if (e != null) {
- conversionError = conversionError.replace("{1}",
- e.getLocalizedMessage());
+ if (conversionError != null) {
+ if (dataSourceType != null) {
+ conversionError = conversionError.replace("{0}",
+ dataSourceType.getSimpleName());
+ }
+ if (e != null) {
+ conversionError = conversionError.replace("{1}",
+ e.getLocalizedMessage());
+ }
}
-
return conversionError;
}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionError.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionError.java
index ad762f8931..887f1b8ff3 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionError.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionError.java
@@ -54,6 +54,21 @@ public class AbsFieldValueConversionError extends TestCase {
}
+ public void testNullConversionMessages() {
+ TextField tf = new TextField();
+ tf.setConverter(new StringToIntegerConverter());
+ tf.setPropertyDataSource(new MethodProperty<String>(paulaBean, "age"));
+ tf.setConversionError(null);
+ tf.setValue("abc");
+ try {
+ tf.validate();
+ fail();
+ } catch (InvalidValueException e) {
+ Assert.assertEquals(null, e.getMessage());
+ }
+
+ }
+
public void testDefaultConversionErrorMessage() {
TextField tf = new TextField();
tf.setConverter(new StringToIntegerConverter());