useSpringBinding bug fix
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.binding.convert;
|
||||
|
||||
import org.springframework.core.style.StylerUtils;
|
||||
|
||||
/**
|
||||
* Thrown when an attempt to execute a type conversion fails.
|
||||
*
|
||||
@@ -87,8 +89,8 @@ public class ConversionExecutionException extends ConversionException {
|
||||
}
|
||||
|
||||
private static String defaultMessage(Object value, Class sourceClass, Class targetClass, Throwable cause) {
|
||||
return "Unable to convert value " + value + " from type '" + sourceClass.getName() + "' to type '"
|
||||
+ targetClass.getName() + "; reason = '" + cause.getMessage() + "'";
|
||||
return "Unable to convert value " + StylerUtils.style(value) + " from type '" + sourceClass.getName()
|
||||
+ "' to type '" + targetClass.getName() + "'; reason = '" + cause.getMessage() + "'";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.NotReadablePropertyException;
|
||||
import org.springframework.beans.NotWritablePropertyException;
|
||||
import org.springframework.binding.convert.ConversionException;
|
||||
import org.springframework.binding.convert.ConversionExecutor;
|
||||
import org.springframework.binding.convert.ConversionService;
|
||||
import org.springframework.binding.expression.EvaluationException;
|
||||
@@ -135,7 +136,15 @@ public class BeanWrapperExpression implements Expression {
|
||||
}
|
||||
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(converter.execute(text));
|
||||
try {
|
||||
Object convertedValue = converter.execute(text);
|
||||
setValue(convertedValue);
|
||||
} catch (ConversionException e) {
|
||||
IllegalArgumentException iae = new IllegalArgumentException("Unable to convert text '" + text + "'");
|
||||
iae.initCause(e);
|
||||
throw iae;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user