Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
b670b194
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b670b194
编写于
2月 09, 2010
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
setAutoGrowNestedPaths throws an IllegalStateException if being called too late (SPR-6718)
上级
aafe8ef9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
24 deletion
+28
-24
org.springframework.context/src/main/java/org/springframework/validation/DataBinder.java
.../main/java/org/springframework/validation/DataBinder.java
+28
-24
未找到文件。
org.springframework.context/src/main/java/org/springframework/validation/DataBinder.java
浏览文件 @
b670b194
/*
/*
* Copyright 2002-20
09
the original author or authors.
* Copyright 2002-20
10
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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录