From ae03c4d29a24c063c4a1f98a23ee544f050ba777 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Mon, 19 Oct 2009 01:06:44 +0000 Subject: [PATCH] SPR-6245 bean wrapper copy constructor not copying all state git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2153 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../beans/AbstractPropertyAccessor.java | 2 -- .../org/springframework/beans/BeanWrapperImpl.java | 13 ++++++++++++- .../ui/format/support/GenericFormatterRegistry.java | 6 +++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java b/org.springframework.beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java index d20a8ededac..4a2f380d81d 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java @@ -21,8 +21,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.springframework.core.convert.ConversionService; - /** * Abstract implementation of the {@link PropertyAccessor} interface. * Provides base implementations of all convenience methods, with the diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java b/org.springframework.beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java index 2be03355dbf..356dc09f253 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java @@ -37,7 +37,6 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.springframework.core.CollectionFactory; import org.springframework.core.GenericCollectionTypeResolver; import org.springframework.core.MethodParameter; @@ -179,6 +178,9 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra private BeanWrapperImpl(Object object, String nestedPath, BeanWrapperImpl superBw) { setWrappedInstance(object, nestedPath, superBw.getWrappedInstance()); setExtractOldValueForEditor(superBw.isExtractOldValueForEditor()); + setAutoGrowNestedPaths(superBw.isAutoGrowNestedPaths()); + setConversionService(superBw.getConversionService()); + setSecurityContext(superBw.acc); } @@ -253,10 +255,19 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra return (this.rootObject != null ? this.rootObject.getClass() : null); } + /** + * If this BeanWrapper should "auto grow" nested paths. + * When true, auto growth is triggered on nested paths when null values are encountered. + * When true, auto growth is triggered on collection properties when out of bounds indexes are accessed. + * Default is false. + */ public void setAutoGrowNestedPaths(boolean autoGrowNestedPaths) { this.autoGrowNestedPaths = autoGrowNestedPaths; } + /** + * If this BeanWrapper should "auto grow" nested paths. + */ public boolean isAutoGrowNestedPaths() { return this.autoGrowNestedPaths; } diff --git a/org.springframework.context/src/main/java/org/springframework/ui/format/support/GenericFormatterRegistry.java b/org.springframework.context/src/main/java/org/springframework/ui/format/support/GenericFormatterRegistry.java index cfe961216aa..5d7fefdc0eb 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/format/support/GenericFormatterRegistry.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/format/support/GenericFormatterRegistry.java @@ -273,10 +273,10 @@ public class GenericFormatterRegistry implements FormatterRegistry, ApplicationC if (factory != null) { return factory.getFormatterHolder(annotation); } else { - Formatted formattedAnnotation = annotationType.getAnnotation(Formatted.class); - if (formattedAnnotation != null) { + Formatted formatted = annotationType.getAnnotation(Formatted.class); + if (formatted != null) { // property annotation has @Formatted meta-annotation - Formatter formatter = createFormatter(formattedAnnotation.value()); + Formatter formatter = createFormatter(formatted.value()); addFormatterByAnnotation(annotationType, formatter); return findFormatterHolderForAnnotation(annotation); } else {