Browse Source

FixedJsonView

conversation
Arjen Poutsma 16 years ago
parent
commit
ef67fc245f
  1. 2
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/json/BindingJacksonJsonView.java
  2. 4
      org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/view/json/BindingJacksonJsonViewTest.java

2
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/json/BindingJacksonJsonView.java

@ -139,7 +139,7 @@ public class BindingJacksonJsonView extends AbstractView { @@ -139,7 +139,7 @@ public class BindingJacksonJsonView extends AbstractView {
Set<String> renderedAttributes =
!CollectionUtils.isEmpty(this.renderedAttributes) ? this.renderedAttributes : model.keySet();
for (Map.Entry<String, Object> 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());
}
}

4
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; @@ -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; @@ -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 { @@ -72,6 +74,7 @@ public class BindingJacksonJsonViewTest {
public void renderSimpleMap() throws Exception {
Map<String, Object> model = new HashMap<String, Object>();
model.put("bindingResult", createMock("binding_result", BindingResult.class));
model.put("foo", "bar");
view.render(model, request, response);
@ -95,6 +98,7 @@ public class BindingJacksonJsonViewTest { @@ -95,6 +98,7 @@ public class BindingJacksonJsonViewTest {
Object bean = new TestBeanSimple();
Map<String, Object> model = new HashMap<String, Object>();
model.put("bindingResult", createMock("binding_result", BindingResult.class));
model.put("foo", bean);
view.render(model, request, response);

Loading…
Cancel
Save