Deprecated FormTag's "commandName" in favor of "modelAttribute"
Issue: SPR-14094
This commit is contained in:
parent
26bbb6e767
commit
2dae4d8134
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2016 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.
|
||||||
|
@ -147,7 +147,9 @@ public class FormTag extends AbstractHtmlElementTag {
|
||||||
* Set the name of the form attribute in the model.
|
* Set the name of the form attribute in the model.
|
||||||
* <p>May be a runtime expression.
|
* <p>May be a runtime expression.
|
||||||
* @see #setModelAttribute
|
* @see #setModelAttribute
|
||||||
|
* @deprecated as of Spring 4.3, in favor of {@link #setModelAttribute}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setCommandName(String commandName) {
|
public void setCommandName(String commandName) {
|
||||||
this.modelAttribute = commandName;
|
this.modelAttribute = commandName;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +157,9 @@ public class FormTag extends AbstractHtmlElementTag {
|
||||||
/**
|
/**
|
||||||
* Get the name of the form attribute in the model.
|
* Get the name of the form attribute in the model.
|
||||||
* @see #getModelAttribute
|
* @see #getModelAttribute
|
||||||
|
* @deprecated as of Spring 4.3, in favor of {@link #getModelAttribute}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
protected String getCommandName() {
|
protected String getCommandName() {
|
||||||
return this.modelAttribute;
|
return this.modelAttribute;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
version="2.0">
|
version="2.0">
|
||||||
|
|
||||||
<description>Spring Framework JSP Form Tag Library</description>
|
<description>Spring Framework JSP Form Tag Library</description>
|
||||||
<tlib-version>4.0</tlib-version>
|
<tlib-version>4.3</tlib-version>
|
||||||
<short-name>form</short-name>
|
<short-name>form</short-name>
|
||||||
<uri>http://www.springframework.org/tags/form</uri>
|
<uri>http://www.springframework.org/tags/form</uri>
|
||||||
|
|
||||||
|
@ -131,8 +131,7 @@
|
||||||
<rtexprvalue>true</rtexprvalue>
|
<rtexprvalue>true</rtexprvalue>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute>
|
<attribute>
|
||||||
<description>Name of the model attribute under which the form object is exposed.
|
<description>DEPRECATED: Use "modelAttribute" instead.</description>
|
||||||
Defaults to 'command'.</description>
|
|
||||||
<name>commandName</name>
|
<name>commandName</name>
|
||||||
<required>false</required>
|
<required>false</required>
|
||||||
<rtexprvalue>true</rtexprvalue>
|
<rtexprvalue>true</rtexprvalue>
|
||||||
|
|
|
@ -528,11 +528,6 @@ Renders an HTML 'form' tag and exposes a binding path to inner tags for binding.
|
||||||
| true
|
| true
|
||||||
| HTML Required Attribute
|
| HTML Required Attribute
|
||||||
|
|
||||||
| commandName
|
|
||||||
| false
|
|
||||||
| true
|
|
||||||
| Name of the model attribute under which the form object is exposed. Defaults to 'command'.
|
|
||||||
|
|
||||||
| cssClass
|
| cssClass
|
||||||
| false
|
| false
|
||||||
| true
|
| true
|
||||||
|
|
|
@ -292,13 +292,10 @@ directly, the files are called spring.vm / spring.ftl and are in the packages
|
||||||
|
|
||||||
[[view-simple-binding]]
|
[[view-simple-binding]]
|
||||||
==== Simple binding
|
==== Simple binding
|
||||||
In your html forms (vm / ftl templates) that act as the 'formView' for a Spring form
|
In your HTML forms (vm / ftl templates) which act as a form view for a Spring MVC
|
||||||
controller, you can use code similar to the following to bind to field values and
|
controller, you can use code similar to the following to bind to field values and
|
||||||
display error messages for each input field in similar fashion to the JSP equivalent.
|
display error messages for each input field in similar fashion to the JSP equivalent.
|
||||||
Note that the name of the command object is "command" by default, but can be overridden
|
Example code is shown below for the `personFormV`/`personFormF` views configured earlier:
|
||||||
in your MVC configuration by setting the 'commandName' bean property on your form
|
|
||||||
controller. Example code is shown below for the `personFormV` and `personFormF` views
|
|
||||||
configured earlier;
|
|
||||||
|
|
||||||
[source,xml,indent=0]
|
[source,xml,indent=0]
|
||||||
[subs="verbatim,quotes"]
|
[subs="verbatim,quotes"]
|
||||||
|
@ -308,7 +305,7 @@ configured earlier;
|
||||||
...
|
...
|
||||||
<form action="" method="POST">
|
<form action="" method="POST">
|
||||||
Name:
|
Name:
|
||||||
#springBind( "command.name" )
|
#springBind("myModelObject.name")
|
||||||
<input type="text"
|
<input type="text"
|
||||||
name="${status.expression}"
|
name="${status.expression}"
|
||||||
value="$!status.value"/><br>
|
value="$!status.value"/><br>
|
||||||
|
@ -331,7 +328,7 @@ configured earlier;
|
||||||
...
|
...
|
||||||
<form action="" method="POST">
|
<form action="" method="POST">
|
||||||
Name:
|
Name:
|
||||||
<@spring.bind "command.name"/>
|
<@spring.bind "myModelObject.name"/>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
name="${spring.status.expression}"
|
name="${spring.status.expression}"
|
||||||
value="${spring.status.value?default("")}"/><br>
|
value="${spring.status.value?default("")}"/><br>
|
||||||
|
@ -818,7 +815,7 @@ The preceding JSP assumes that the variable name of the form backing object is
|
||||||
[source,xml,indent=0]
|
[source,xml,indent=0]
|
||||||
[subs="verbatim,quotes"]
|
[subs="verbatim,quotes"]
|
||||||
----
|
----
|
||||||
<form:form commandName="user">
|
<form:form modelAttribute="user">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>First Name:</td>
|
<td>First Name:</td>
|
||||||
|
|
Loading…
Reference in New Issue