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;
}
}
+ 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());