fixed getPropertyTypeDescriptor to work for nested indexed property as well (SPR-6710)
This commit is contained in:
parent
a70bb40b3d
commit
5abd3b99b9
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2010 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -355,8 +355,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
|
|
||||||
public TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException {
|
public TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException {
|
||||||
try {
|
try {
|
||||||
String canonicalName = PropertyAccessorUtils.getPropertyName(propertyName);
|
PropertyDescriptor pd = getPropertyDescriptorInternal(propertyName);
|
||||||
PropertyDescriptor pd = getPropertyDescriptorInternal(canonicalName);
|
|
||||||
if (pd != null) {
|
if (pd != null) {
|
||||||
Class type = getPropertyType(propertyName);
|
Class type = getPropertyType(propertyName);
|
||||||
if (pd.getReadMethod() != null) {
|
if (pd.getReadMethod() != null) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2010 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -16,8 +16,10 @@
|
||||||
|
|
||||||
package org.springframework.format.datetime.joda;
|
package org.springframework.format.datetime.joda;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
@ -55,7 +57,9 @@ public class JodaTimeFormattingTests {
|
||||||
JodaTimeFormattingConfigurer configurer = new JodaTimeFormattingConfigurer();
|
JodaTimeFormattingConfigurer configurer = new JodaTimeFormattingConfigurer();
|
||||||
configurer.installJodaTimeFormatting(conversionService);
|
configurer.installJodaTimeFormatting(conversionService);
|
||||||
|
|
||||||
binder = new DataBinder(new JodaTimeBean());
|
JodaTimeBean bean = new JodaTimeBean();
|
||||||
|
bean.getChildren().add(new JodaTimeBean());
|
||||||
|
binder = new DataBinder(bean);
|
||||||
binder.setConversionService(conversionService);
|
binder.setConversionService(conversionService);
|
||||||
|
|
||||||
LocaleContextHolder.setLocale(Locale.US);
|
LocaleContextHolder.setLocale(Locale.US);
|
||||||
|
|
@ -104,6 +108,15 @@ public class JodaTimeFormattingTests {
|
||||||
assertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated"));
|
assertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBindNestedLocalDateAnnotated() {
|
||||||
|
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||||
|
propertyValues.add("children[0].localDateAnnotated", "Oct 31, 2009");
|
||||||
|
binder.bind(propertyValues);
|
||||||
|
assertEquals(0, binder.getBindingResult().getErrorCount());
|
||||||
|
assertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("children[0].localDateAnnotated"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBindLocalDateAnnotatedWithDirectFieldAccess() {
|
public void testBindLocalDateAnnotatedWithDirectFieldAccess() {
|
||||||
binder.initDirectFieldAccess();
|
binder.initDirectFieldAccess();
|
||||||
|
|
@ -337,6 +350,8 @@ public class JodaTimeFormattingTests {
|
||||||
@DateTimeFormat(iso=ISO.DATE_TIME)
|
@DateTimeFormat(iso=ISO.DATE_TIME)
|
||||||
private DateTime isoDateTime;
|
private DateTime isoDateTime;
|
||||||
|
|
||||||
|
private final List<JodaTimeBean> children = new ArrayList<JodaTimeBean>();
|
||||||
|
|
||||||
public LocalDate getLocalDate() {
|
public LocalDate getLocalDate() {
|
||||||
return localDate;
|
return localDate;
|
||||||
}
|
}
|
||||||
|
|
@ -497,5 +512,9 @@ public class JodaTimeFormattingTests {
|
||||||
this.isoDateTime = isoDateTime;
|
this.isoDateTime = isoDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<JodaTimeBean> getChildren() {
|
||||||
|
return children;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue