list binding working

master
Keith Donald 15 years ago
parent 14dd30c5a5
commit 4e50c51139
  1. 10
      org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinder.java
  2. 2
      org.springframework.context/src/main/java/org/springframework/ui/binding/support/PropertyPath.java
  3. 1
      org.springframework.context/src/test/java/org/springframework/ui/binding/support/GenericBinderTests.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<String, Binding> nestedBindings = new HashMap<String, Binding>();
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() {

@ -23,7 +23,7 @@ public class PropertyPath implements Iterable<PropertyPathElement> {
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));

@ -347,7 +347,6 @@ public class GenericBinderTests {
}
@Test
@Ignore
public void bindToListHandleNullValueInNestedPath() {
Map<String, String> values = new LinkedHashMap<String, String>();
// - new addresses List is created if null

Loading…
Cancel
Save