diff --git a/org.springframework.web.servlet/pom.xml b/org.springframework.web.servlet/pom.xml
index ece6c7c9cbf..29e7639e8ef 100644
--- a/org.springframework.web.servlet/pom.xml
+++ b/org.springframework.web.servlet/pom.xml
@@ -126,7 +126,13 @@
1.1.2
true
-
+
+
velocity
velocity
1.5
diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityView.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityView.java
index 6699f514bb4..3637c8799f1 100644
--- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityView.java
+++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/velocity/VelocityView.java
@@ -73,6 +73,7 @@ import org.springframework.web.util.NestedServletException;
*
* @author Rod Johnson
* @author Juergen Hoeller
+ * @author Dave Syer
* @see VelocityConfig
* @see VelocityConfigurer
* @see #setUrl
@@ -516,11 +517,12 @@ public class VelocityView extends AbstractTemplateView {
template.merge(context, response.getWriter());
}
catch (MethodInvocationException ex) {
+ Throwable cause = ex.getWrappedThrowable();
throw new NestedServletException(
"Method invocation failed during rendering of Velocity view with name '" +
getBeanName() + "': " + ex.getMessage() + "; reference [" + ex.getReferenceName() +
"], method '" + ex.getMethodName() + "'",
- ex.getWrappedThrowable());
+ cause==null ? ex : cause);
}
}
diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java
index 46713c612c9..69df3655264 100644
--- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java
+++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java
@@ -50,6 +50,7 @@ import org.springframework.web.servlet.tags.TransformTag;
* @author Rob Harrop
* @author Juergen Hoeller
* @author Jeremy Grelle
+ * @author Dave Syer
*/
public class SelectTagTests extends AbstractFormTagTests {
@@ -172,7 +173,7 @@ public class SelectTagTests extends AbstractFormTagTests {
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(getTestBean(), "testBean");
bindingResult.getPropertyAccessor().registerCustomEditor(Country.class, new PropertyEditorSupport() {
public void setAsText(String text) throws IllegalArgumentException {
- setValue(new Country(text, ""));
+ setValue(Country.getCountryWithIsoCode(text));
}
public String getAsText() {
return ((Country) getValue()).getName();
@@ -187,9 +188,122 @@ public class SelectTagTests extends AbstractFormTagTests {
transformTag.setParent(this.tag);
transformTag.setPageContext(getPageContext());
transformTag.doStartTag();
+ String output = getOutput();
+ System.err.println(output);
assertEquals("Austria", getPageContext().findAttribute("key"));
}
+ public void testWithListAndEditor() throws Exception {
+ this.tag.setPath("realCountry");
+ this.tag.setItems("${countries}");
+ this.tag.setItemValue("isoCode");
+ this.tag.setItemLabel("name");
+ BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(getTestBean(), "testBean");
+ bindingResult.getPropertyAccessor().registerCustomEditor(Country.class, new PropertyEditorSupport() {
+ public void setAsText(String text) throws IllegalArgumentException {
+ setValue(Country.getCountryWithIsoCode(text));
+ }
+ public String getAsText() {
+ return ((Country) getValue()).getName();
+ }
+ });
+ getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
+ this.tag.doStartTag();
+ String output = getOutput();
+ assertTrue(output.startsWith("