Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
bba8bb6e
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,体验更适合开发者的 AI 搜索 >>
提交
bba8bb6e
编写于
11月 03, 2011
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SPR-8661 Add disabled attribute to HiddenInputTag
上级
78fbceff
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
73 addition
and
4 deletion
+73
-4
build-spring-framework/resources/changelog.txt
build-spring-framework/resources/changelog.txt
+1
-0
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/HiddenInputTag.java
...springframework/web/servlet/tags/form/HiddenInputTag.java
+33
-1
org.springframework.web.servlet/src/main/resources/META-INF/spring-form.tld
...k.web.servlet/src/main/resources/META-INF/spring-form.tld
+6
-0
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java
...gframework/web/servlet/tags/form/HiddenInputTagTests.java
+33
-3
未找到文件。
build-spring-framework/resources/changelog.txt
浏览文件 @
bba8bb6e
...
...
@@ -19,6 +19,7 @@ Changes in version 3.1 RC2 (2011-11-15)
* Support target request with multiple parameter values in FlahMap matching logic
* Fix issue in SimpleMappingExceptionResolver causing exception when setting "statusCodes" property
* The Form input tag allows type values other than "text" such as HTML5-specific types.
* The Form hidden tag supports "disabled" attribute
Changes in version 3.1 RC1 (2011-10-11)
---------------------------------------
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/HiddenInputTag.java
浏览文件 @
bba8bb6e
...
...
@@ -35,6 +35,28 @@ import javax.servlet.jsp.JspException;
@SuppressWarnings
(
"serial"
)
public
class
HiddenInputTag
extends
AbstractHtmlElementTag
{
/**
* The name of the '<code>disabled</code>' attribute.
*/
public
static
final
String
DISABLED_ATTRIBUTE
=
"disabled"
;
private
String
disabled
;
/**
* Get the value of the '<code>disabled</code>' attribute.
*/
public
String
getDisabled
()
{
return
this
.
disabled
;
}
/**
* Set the value of the '<code>disabled</code>' attribute.
* May be a runtime expression.
*/
public
void
setDisabled
(
String
disabled
)
{
this
.
disabled
=
disabled
;
}
/**
* Flags "type" as an illegal dynamic attribute.
*/
...
...
@@ -54,10 +76,20 @@ public class HiddenInputTag extends AbstractHtmlElementTag {
tagWriter
.
startTag
(
"input"
);
writeDefaultAttributes
(
tagWriter
);
tagWriter
.
writeAttribute
(
"type"
,
"hidden"
);
if
(
isDisabled
())
{
tagWriter
.
writeAttribute
(
DISABLED_ATTRIBUTE
,
"disabled"
);
}
String
value
=
getDisplayString
(
getBoundValue
(),
getPropertyEditor
());
tagWriter
.
writeAttribute
(
"value"
,
processFieldValue
(
getName
(),
value
,
"hidden"
));
tagWriter
.
endTag
();
return
SKIP_BODY
;
}
/**
* Is the current HTML tag disabled?
*/
protected
boolean
isDisabled
()
throws
JspException
{
return
evaluateBoolean
(
DISABLED_ATTRIBUTE
,
getDisabled
());
}
}
org.springframework.web.servlet/src/main/resources/META-INF/spring-form.tld
浏览文件 @
bba8bb6e
...
...
@@ -652,6 +652,12 @@
<required>
false
</required>
<rtexprvalue>
true
</rtexprvalue>
</attribute>
<attribute>
<description>
HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element.
</description>
<name>
disabled
</name>
<required>
false
</required>
<rtexprvalue>
true
</rtexprvalue>
</attribute>
<attribute>
<description>
HTML Event Attribute
</description>
<name>
onclick
</name>
...
...
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java
浏览文件 @
bba8bb6e
...
...
@@ -16,12 +16,12 @@
package
org.springframework.web.servlet.tags.form
;
import
org.springframework.beans.TestBean
;
import
org.springframework.validation.BeanPropertyBindingResult
;
import
javax.servlet.jsp.JspException
;
import
javax.servlet.jsp.tagext.Tag
;
import
org.springframework.beans.TestBean
;
import
org.springframework.validation.BeanPropertyBindingResult
;
/**
* @author Rob Harrop
*/
...
...
@@ -31,6 +31,7 @@ public class HiddenInputTagTests extends AbstractFormTagTests {
private
TestBean
bean
;
@SuppressWarnings
(
"serial"
)
protected
void
onSetUp
()
{
this
.
tag
=
new
HiddenInputTag
()
{
protected
TagWriter
createTagWriter
()
{
...
...
@@ -52,6 +53,7 @@ public class HiddenInputTagTests extends AbstractFormTagTests {
assertContainsAttribute
(
output
,
"type"
,
"hidden"
);
assertContainsAttribute
(
output
,
"value"
,
"Sally Greenwood"
);
assertAttributeNotPresent
(
output
,
"disabled"
);
}
public
void
testWithCustomBinder
()
throws
Exception
{
...
...
@@ -82,6 +84,34 @@ public class HiddenInputTagTests extends AbstractFormTagTests {
}
}
public
void
testDisabledTrue
()
throws
Exception
{
this
.
tag
.
setDisabled
(
"true"
);
this
.
tag
.
doStartTag
();
this
.
tag
.
doEndTag
();
String
output
=
getOutput
();
assertTagOpened
(
output
);
assertTagClosed
(
output
);
assertContainsAttribute
(
output
,
"disabled"
,
"disabled"
);
}
// SPR-8661
public
void
testDisabledFalse
()
throws
Exception
{
this
.
tag
.
setDisabled
(
"false"
);
this
.
tag
.
doStartTag
();
this
.
tag
.
doEndTag
();
String
output
=
getOutput
();
assertTagOpened
(
output
);
assertTagClosed
(
output
);
assertAttributeNotPresent
(
output
,
"disabled"
);
}
private
void
assertTagClosed
(
String
output
)
{
assertTrue
(
output
.
endsWith
(
"/>"
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录