FixedJsonView

This commit is contained in:
Arjen Poutsma 2009-07-01 09:40:11 +00:00
parent 7e05c928dd
commit ef67fc245f
2 changed files with 5 additions and 1 deletions

View File

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

View File

@ -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<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 {
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);