Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
db487b6d
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,发现更多精彩内容 >>
提交
db487b6d
编写于
7月 29, 2009
作者:
K
Keith Donald
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixe bug in element type for jeremyg
上级
17dfc8b0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
23 deletion
+26
-23
org.springframework.context/src/main/java/org/springframework/model/ui/support/DefaultPresentationModel.java
...gframework/model/ui/support/DefaultPresentationModel.java
+26
-23
未找到文件。
org.springframework.context/src/main/java/org/springframework/model/ui/support/DefaultPresentationModel.java
浏览文件 @
db487b6d
...
...
@@ -144,15 +144,15 @@ public class DefaultPresentationModel implements PresentationModel {
}
public
void
validate
()
{
}
public
boolean
hasErrors
()
{
return
false
;
}
public
void
commit
()
{
}
// internal helpers
...
...
@@ -192,7 +192,7 @@ public class DefaultPresentationModel implements PresentationModel {
private
Map
<
Integer
,
FieldModel
>
listElements
;
private
Map
<
Object
,
FieldModel
>
mapValues
;
public
PropertyFieldModelRule
(
String
property
,
Class
domainModelClass
)
{
this
.
domainModelClass
=
domainModelClass
;
this
.
property
=
findPropertyDescriptor
(
property
);
...
...
@@ -247,7 +247,7 @@ public class DefaultPresentationModel implements PresentationModel {
public
String
getLabel
()
{
return
property
.
getName
();
}
public
FieldModel
getNested
(
String
fieldName
)
{
createValueIfNecessary
();
return
getNestedRule
(
fieldName
,
fieldModel
.
getValueType
()).
getFieldModel
(
fieldModel
.
getValue
());
...
...
@@ -277,7 +277,8 @@ public class DefaultPresentationModel implements PresentationModel {
FieldModel
field
=
mapValues
.
get
(
key
);
if
(
field
==
null
)
{
FieldModelContext
context
=
new
MapValueContext
(
key
,
this
);
ValueModel
valueModel
=
new
MapValueValueModel
(
key
,
getElementType
(),
(
Map
)
fieldModel
.
getValue
(),
context
);
ValueModel
valueModel
=
new
MapValueValueModel
(
key
,
getElementType
(),
(
Map
)
fieldModel
.
getValue
(),
context
);
field
=
new
DefaultFieldModel
(
valueModel
,
context
);
mapValues
.
put
(
key
,
field
);
}
...
...
@@ -293,8 +294,7 @@ public class DefaultPresentationModel implements PresentationModel {
public
FieldModelConfiguration
formatElementsWith
(
Formatter
<?>
formatter
)
{
if
(!
List
.
class
.
isAssignableFrom
(
domainModelClass
)
||
domainModelClass
.
isArray
())
{
throw
new
IllegalStateException
(
"Field is not a List or an Array; cannot set a element formatter"
);
throw
new
IllegalStateException
(
"Field is not a List or an Array; cannot set a element formatter"
);
}
elementFormatter
=
formatter
;
return
this
;
...
...
@@ -324,7 +324,7 @@ public class DefaultPresentationModel implements PresentationModel {
}
// package private helpers
PropertyFieldModelRule
getNestedRule
(
String
propertyName
)
{
return
getNestedRule
(
propertyName
,
this
.
property
.
getPropertyType
());
}
...
...
@@ -344,10 +344,13 @@ public class DefaultPresentationModel implements PresentationModel {
// internal helpers
private
Class
<?>
getElementType
()
{
if
(
Map
.
class
.
isAssignableFrom
(
property
.
getPropertyType
()))
{
return
GenericCollectionTypeResolver
.
getMapValueReturnType
(
property
.
getReadMethod
());
Class
<?>
propertyType
=
property
.
getPropertyType
();
if
(
Map
.
class
.
isAssignableFrom
(
propertyType
))
{
return
GenericCollectionTypeResolver
.
getMapValueReturnType
(
property
.
getReadMethod
());
}
else
if
(
propertyType
.
isArray
())
{
return
property
.
getPropertyType
().
getComponentType
();
}
else
{
return
GenericCollectionTypeResolver
.
getCollectionReturnType
(
property
.
getReadMethod
());
return
GenericCollectionTypeResolver
.
getCollectionReturnType
(
property
.
getReadMethod
());
}
}
...
...
@@ -396,9 +399,9 @@ public class DefaultPresentationModel implements PresentationModel {
value
=
newMapValue
(
fieldModel
.
getValueType
());
fieldModel
.
applySubmittedValue
(
value
);
fieldModel
.
commit
();
}
}
}
private
void
growListIfNecessary
(
int
index
)
{
List
list
=
(
List
)
fieldModel
.
getValue
();
if
(
list
==
null
)
{
...
...
@@ -443,18 +446,18 @@ public class DefaultPresentationModel implements PresentationModel {
}
private
static
class
ListElementContext
implements
FieldModelContext
{
private
int
index
;
private
PropertyFieldModelRule
listBindingContext
;
final
Map
<
String
,
FieldModel
>
nestedBindings
=
new
HashMap
<
String
,
FieldModel
>();
public
ListElementContext
(
int
index
,
PropertyFieldModelRule
listBindingContext
)
{
this
.
index
=
index
;
this
.
listBindingContext
=
listBindingContext
;
}
public
MessageSource
getMessageSource
()
{
return
listBindingContext
.
getMessageSource
();
}
...
...
@@ -522,20 +525,20 @@ public class DefaultPresentationModel implements PresentationModel {
throw
new
IllegalArgumentException
(
"Not yet supported"
);
}
};
private
static
class
MapValueContext
implements
FieldModelContext
{
private
Object
key
;
private
PropertyFieldModelRule
mapContext
;
final
Map
<
String
,
FieldModel
>
nestedBindings
=
new
HashMap
<
String
,
FieldModel
>();
public
MapValueContext
(
Object
key
,
PropertyFieldModelRule
mapContext
)
{
this
.
key
=
key
;
this
.
mapContext
=
mapContext
;
}
public
MessageSource
getMessageSource
()
{
return
mapContext
.
getMessageSource
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录