setAutoGrowNestedPaths throws an IllegalStateException if being called too late (SPR-6718)
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2939 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
4561a6a9c3
commit
439b6f072c
|
|
@ -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.
|
||||||
|
|
@ -176,14 +176,37 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
||||||
return this.objectName;
|
return this.objectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether this binder should attempt to "auto-grow" a nested path that contains a null value.
|
||||||
|
* <p>If "true", a null path location will be populated with a default object value and traversed
|
||||||
|
* instead of resulting in an exception. This flag also enables auto-growth of collection elements
|
||||||
|
* when accessing an out-of-bounds index.
|
||||||
|
* <p>Default is "true" on a standard DataBinder. Note that this feature is only supported
|
||||||
|
* for bean property access (DataBinder's default mode), not for field access.
|
||||||
|
* @see #initBeanPropertyAccess()
|
||||||
|
* @see org.springframework.beans.BeanWrapper#setAutoGrowNestedPaths
|
||||||
|
*/
|
||||||
|
public void setAutoGrowNestedPaths(boolean autoGrowNestedPaths) {
|
||||||
|
Assert.state(this.bindingResult == null,
|
||||||
|
"DataBinder is already initialized - call setAutoGrowNestedPaths before other configuration methods");
|
||||||
|
this.autoGrowNestedPaths = autoGrowNestedPaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether "auto-growing" of nested paths has been activated.
|
||||||
|
*/
|
||||||
|
public boolean isAutoGrowNestedPaths() {
|
||||||
|
return this.autoGrowNestedPaths;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize standard JavaBean property access for this DataBinder.
|
* Initialize standard JavaBean property access for this DataBinder.
|
||||||
* <p>This is the default; an explicit call just leads to eager initialization.
|
* <p>This is the default; an explicit call just leads to eager initialization.
|
||||||
* @see #initDirectFieldAccess()
|
* @see #initDirectFieldAccess()
|
||||||
*/
|
*/
|
||||||
public void initBeanPropertyAccess() {
|
public void initBeanPropertyAccess() {
|
||||||
Assert.isNull(this.bindingResult,
|
Assert.state(this.bindingResult == null,
|
||||||
"DataBinder is already initialized - call initBeanPropertyAccess before any other configuration methods");
|
"DataBinder is already initialized - call initBeanPropertyAccess before other configuration methods");
|
||||||
this.bindingResult = new BeanPropertyBindingResult(getTarget(), getObjectName(), isAutoGrowNestedPaths());
|
this.bindingResult = new BeanPropertyBindingResult(getTarget(), getObjectName(), isAutoGrowNestedPaths());
|
||||||
if (this.conversionService != null) {
|
if (this.conversionService != null) {
|
||||||
this.bindingResult.initConversion(this.conversionService);
|
this.bindingResult.initConversion(this.conversionService);
|
||||||
|
|
@ -196,8 +219,8 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
||||||
* @see #initBeanPropertyAccess()
|
* @see #initBeanPropertyAccess()
|
||||||
*/
|
*/
|
||||||
public void initDirectFieldAccess() {
|
public void initDirectFieldAccess() {
|
||||||
Assert.isNull(this.bindingResult,
|
Assert.state(this.bindingResult == null,
|
||||||
"DataBinder is already initialized - call initDirectFieldAccess before any other configuration methods");
|
"DataBinder is already initialized - call initDirectFieldAccess before other configuration methods");
|
||||||
this.bindingResult = new DirectFieldBindingResult(getTarget(), getObjectName());
|
this.bindingResult = new DirectFieldBindingResult(getTarget(), getObjectName());
|
||||||
if (this.conversionService != null) {
|
if (this.conversionService != null) {
|
||||||
this.bindingResult.initConversion(this.conversionService);
|
this.bindingResult.initConversion(this.conversionService);
|
||||||
|
|
@ -332,25 +355,6 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
||||||
return this.ignoreInvalidFields;
|
return this.ignoreInvalidFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether this binder should attempt to "auto-grow" a nested path that contains a null value.
|
|
||||||
* <p>If "true", a null path location will be populated with a default object value and traversed
|
|
||||||
* instead of resulting in an exception. This flag also enables auto-growth of collection elements
|
|
||||||
* when accessing an out-of-bounds index.
|
|
||||||
* <p>Default is "true" on a standard DataBinder.
|
|
||||||
* @see org.springframework.beans.BeanWrapper#setAutoGrowNestedPaths
|
|
||||||
*/
|
|
||||||
public void setAutoGrowNestedPaths(boolean autoGrowNestedPaths) {
|
|
||||||
this.autoGrowNestedPaths = autoGrowNestedPaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return whether "auto-growing" of nested paths has been activated.
|
|
||||||
*/
|
|
||||||
public boolean isAutoGrowNestedPaths() {
|
|
||||||
return this.autoGrowNestedPaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register fields that should be allowed for binding. Default is all
|
* Register fields that should be allowed for binding. Default is all
|
||||||
* fields. Restrict this for example to avoid unwanted modifications
|
* fields. Restrict this for example to avoid unwanted modifications
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue