Browse Source

fixed getPropertyTypeDescriptor to work for nested indexed property as well as for array property (SPR-6710)

pull/23217/head
Juergen Hoeller 15 years ago
parent
commit
081d81e5b0
  1. 3
      org.springframework.beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java
  2. 5
      org.springframework.beans/src/main/java/org/springframework/beans/PropertyAccessorUtils.java

3
org.springframework.beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java

@ -355,7 +355,8 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra @@ -355,7 +355,8 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
public TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException {
try {
PropertyDescriptor pd = getPropertyDescriptorInternal(propertyName);
String actualPropertyName = PropertyAccessorUtils.getPropertyName(propertyName);
PropertyDescriptor pd = getPropertyDescriptorInternal(actualPropertyName);
if (pd != null) {
Class type = getPropertyType(propertyName);
if (pd.getReadMethod() != null) {

5
org.springframework.beans/src/main/java/org/springframework/beans/PropertyAccessorUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,7 +32,8 @@ public abstract class PropertyAccessorUtils { @@ -32,7 +32,8 @@ public abstract class PropertyAccessorUtils {
* @return the actual property name, without any key elements
*/
public static String getPropertyName(String propertyPath) {
int separatorIndex = propertyPath.indexOf(PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR);
int separatorIndex = (propertyPath.endsWith(PropertyAccessor.PROPERTY_KEY_SUFFIX) ?
propertyPath.indexOf(PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR) : -1);
return (separatorIndex != -1 ? propertyPath.substring(0, separatorIndex) : propertyPath);
}

Loading…
Cancel
Save