diff --git a/org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinder.java b/org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinder.java index 235dca54d7..33ae2fd6a5 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinder.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinder.java @@ -126,7 +126,6 @@ public class GenericBinder implements Binder { public Binding getBinding(String property) { PropertyPath path = new PropertyPath(property); Binding binding = getBindingRule(path.getFirstElement().getValue()).getBinding(model); - System.out.println(path); for (PropertyPathElement element : path.getNestedElements()) { if (element.isIndex()) { if (binding.isMap()) { @@ -303,6 +302,7 @@ public class GenericBinder implements Binder { growListIfNecessary(index); Binding binding = listElementBindings.get(index); if (binding == null) { + final Map nestedBindings = new HashMap(); BindingContext listContext = new BindingContext() { public MessageSource getMessageSource() { return GenericBindingRule.this.getMessageSource(); @@ -313,8 +313,14 @@ public class GenericBinder implements Binder { } public Binding getBinding(String property) { + GenericBindingRule rule = GenericBindingRule.this.getBindingRule(property, getElementType()); Object model = ((List) GenericBindingRule.this.binding.getValue()).get(index); - return GenericBindingRule.this.getBindingRule(property, getElementType()).getBinding(model); + Binding binding = nestedBindings.get(property); + if (binding == null) { + binding = new PropertyBinding(rule.property, model, rule); + nestedBindings.put(property, binding); + } + return binding; } public Formatter getFormatter() { diff --git a/org.springframework.context/src/main/java/org/springframework/ui/binding/support/PropertyPath.java b/org.springframework.context/src/main/java/org/springframework/ui/binding/support/PropertyPath.java index 5528a48bdd..c5e2879aaf 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/binding/support/PropertyPath.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/binding/support/PropertyPath.java @@ -23,7 +23,7 @@ public class PropertyPath implements Iterable { int start = prop.indexOf('['); int end = prop.indexOf(']', start); String index = prop.substring(start + 1, end); - elements.add(new PropertyPathElement(prop.substring(0, start), true)); + elements.add(new PropertyPathElement(prop.substring(0, start), false)); elements.add(new PropertyPathElement(index, true)); } else { elements.add(new PropertyPathElement(prop, false)); diff --git a/org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java b/org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java index 984e4b9e50..07e338f02c 100644 --- a/org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java +++ b/org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.java @@ -347,7 +347,6 @@ public class GenericBinderTests { } @Test - @Ignore public void bindToListHandleNullValueInNestedPath() { Map values = new LinkedHashMap(); // - new addresses List is created if null