From ef67fc245f4fae4df483a0e1be462261a3d66b65 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Wed, 1 Jul 2009 09:40:11 +0000 Subject: [PATCH] FixedJsonView --- .../web/servlet/view/json/BindingJacksonJsonView.java | 2 +- .../web/servlet/view/json/BindingJacksonJsonViewTest.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/json/BindingJacksonJsonView.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/json/BindingJacksonJsonView.java index 0c28d742d4..a4740680f0 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/json/BindingJacksonJsonView.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/json/BindingJacksonJsonView.java @@ -139,7 +139,7 @@ public class BindingJacksonJsonView extends AbstractView { Set renderedAttributes = !CollectionUtils.isEmpty(this.renderedAttributes) ? this.renderedAttributes : model.keySet(); for (Map.Entry entry : model.entrySet()) { - if (!(entry instanceof BindingResult) && renderedAttributes.contains(entry.getKey())) { + if (!(entry.getValue() instanceof BindingResult) && renderedAttributes.contains(entry.getKey())) { result.put(entry.getKey(), entry.getValue()); } } diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/view/json/BindingJacksonJsonViewTest.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/view/json/BindingJacksonJsonViewTest.java index 63a91288e9..232de63071 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/view/json/BindingJacksonJsonViewTest.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/view/json/BindingJacksonJsonViewTest.java @@ -31,6 +31,7 @@ import org.codehaus.jackson.map.SerializationConfig; import org.codehaus.jackson.map.SerializerFactory; import org.codehaus.jackson.map.SerializerProvider; import org.codehaus.jackson.map.ser.BeanSerializerFactory; +import static org.easymock.EasyMock.*; import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; @@ -40,6 +41,7 @@ import org.mozilla.javascript.ScriptableObject; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.validation.BindingResult; /** * @author Jeremy Grelle @@ -72,6 +74,7 @@ public class BindingJacksonJsonViewTest { public void renderSimpleMap() throws Exception { Map model = new HashMap(); + model.put("bindingResult", createMock("binding_result", BindingResult.class)); model.put("foo", "bar"); view.render(model, request, response); @@ -95,6 +98,7 @@ public class BindingJacksonJsonViewTest { Object bean = new TestBeanSimple(); Map model = new HashMap(); + model.put("bindingResult", createMock("binding_result", BindingResult.class)); model.put("foo", bean); view.render(model, request, response);