public class FormTag extends AbstractHtmlElementTag
form
' whose
inner elements are bound to properties on a form object.
Users should place the form object into the
ModelAndView
when
populating the data for their view. The name of this form object can be
configured using the "modelAttribute"
property.
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ACCEPT_CHARSET_ATTRIBUTE |
private java.lang.String |
acceptCharset |
private java.lang.String |
action |
private static java.lang.String |
ACTION_ATTRIBUTE |
private java.lang.String |
autocomplete |
private static java.lang.String |
AUTOCOMPLETE_ATTRIBUTE |
static java.lang.String |
DEFAULT_COMMAND_NAME
The default attribute name: "command"
|
private static java.lang.String |
DEFAULT_METHOD
The default HTTP method using which form values are sent to the server: "post"
|
private static java.lang.String |
DEFAULT_METHOD_PARAM
Default method parameter, i.e.
|
private java.lang.String |
enctype |
private static java.lang.String |
ENCTYPE_ATTRIBUTE |
private static java.lang.String |
FORM_TAG |
private static java.lang.String |
INPUT_TAG |
private java.lang.String |
method |
private static java.lang.String |
METHOD_ATTRIBUTE |
private java.lang.String |
methodParam |
private static java.lang.String |
MODEL_ATTRIBUTE
The name of the '
modelAttribute ' setting |
static java.lang.String |
MODEL_ATTRIBUTE_VARIABLE_NAME
The name of the
javax.servlet.jsp.PageContext attribute under which the
form object name is exposed. |
private java.lang.String |
modelAttribute |
private java.lang.String |
name |
private static java.lang.String |
NAME_ATTRIBUTE |
private java.lang.String |
onreset |
private static java.lang.String |
ONRESET_ATTRIBUTE |
private java.lang.String |
onsubmit |
private static java.lang.String |
ONSUBMIT_ATTRIBUTE |
private java.lang.String |
previousNestedPath
Caching a previous nested path, so that it may be reset
|
private java.lang.String |
servletRelativeAction |
private TagWriter |
tagWriter |
private java.lang.String |
target |
private static java.lang.String |
TARGET_ATTRIBUTE |
private static java.lang.String |
TYPE_ATTRIBUTE |
private static java.lang.String |
VALUE_ATTRIBUTE |
CLASS_ATTRIBUTE, DIR_ATTRIBUTE, LANG_ATTRIBUTE, ONCLICK_ATTRIBUTE, ONDBLCLICK_ATTRIBUTE, ONKEYDOWN_ATTRIBUTE, ONKEYPRESS_ATTRIBUTE, ONKEYUP_ATTRIBUTE, ONMOUSEDOWN_ATTRIBUTE, ONMOUSEMOVE_ATTRIBUTE, ONMOUSEOUT_ATTRIBUTE, ONMOUSEOVER_ATTRIBUTE, ONMOUSEUP_ATTRIBUTE, STYLE_ATTRIBUTE, TABINDEX_ATTRIBUTE, TITLE_ATTRIBUTE
NESTED_PATH_VARIABLE_NAME
logger, REQUEST_CONTEXT_PAGE_ATTRIBUTE
Constructor and Description |
---|
FormTag() |
Modifier and Type | Method and Description |
---|---|
private void |
assertHttpMethod(java.lang.String method) |
protected java.lang.String |
autogenerateId()
Autogenerated IDs correspond to the form object name.
|
int |
doEndTag()
Closes the '
form ' block tag and removes the form object name
from the javax.servlet.jsp.PageContext . |
void |
doFinally()
Clears the stored
TagWriter . |
protected java.lang.String |
getAcceptCharset()
Get the value of the '
acceptCharset ' attribute. |
protected java.lang.String |
getAction()
Get the value of the '
action ' attribute. |
protected java.lang.String |
getAutocomplete()
Get the value of the '
autocomplete ' attribute. |
protected java.lang.String |
getCommandName()
Deprecated.
as of Spring 4.3, in favor of
getModelAttribute() |
protected java.lang.String |
getEnctype()
Get the value of the '
enctype ' attribute. |
private java.lang.String |
getHttpMethod() |
protected java.lang.String |
getMethod()
Get the value of the '
method ' attribute. |
protected java.lang.String |
getMethodParam()
Get the name of the request param for non-browser supported HTTP methods.
|
protected java.lang.String |
getMethodParameter()
Deprecated.
as of 4.2.3, in favor of
getMethodParam() which is
a proper pairing for setMethodParam(String) |
protected java.lang.String |
getModelAttribute()
Get the name of the form attribute in the model.
|
protected java.lang.String |
getName()
Get the value of the '
name ' attribute. |
protected java.lang.String |
getOnreset()
Get the value of the '
onreset ' attribute. |
protected java.lang.String |
getOnsubmit()
Get the value of the '
onsubmit ' attribute. |
protected java.lang.String |
getServletRelativeAction()
Get the servlet-relative value of the '
action ' attribute. |
java.lang.String |
getTarget()
Get the value of the '
target ' attribute. |
protected boolean |
isMethodBrowserSupported(java.lang.String method)
Determine if the HTTP method is supported by browsers (i.e.
|
private java.lang.String |
processAction(java.lang.String action)
Process the action through a
RequestDataValueProcessor instance
if one is configured or otherwise returns the action unmodified. |
protected java.lang.String |
resolveAction()
Resolve the value of the '
action ' attribute. |
protected java.lang.String |
resolveCssClass()
Override resolve CSS class since error class is not supported.
|
protected java.lang.String |
resolveModelAttribute()
Resolves and returns the name of the form object. |
void |
setAcceptCharset(java.lang.String acceptCharset)
Set the value of the '
acceptCharset ' attribute. |
void |
setAction(java.lang.String action)
Set the value of the '
action ' attribute. |
void |
setAutocomplete(java.lang.String autocomplete)
Set the value of the '
autocomplete ' attribute. |
void |
setCommandName(java.lang.String commandName)
Deprecated.
as of Spring 4.3, in favor of
setModelAttribute(java.lang.String) |
void |
setCssErrorClass(java.lang.String cssErrorClass)
Unsupported for forms.
|
void |
setEnctype(java.lang.String enctype)
Set the value of the '
enctype ' attribute. |
void |
setMethod(java.lang.String method)
Set the value of the '
method ' attribute. |
void |
setMethodParam(java.lang.String methodParam)
Set the name of the request param for non-browser supported HTTP methods.
|
void |
setModelAttribute(java.lang.String modelAttribute)
Set the name of the form attribute in the model.
|
void |
setName(java.lang.String name)
Set the value of the '
name ' attribute. |
void |
setOnreset(java.lang.String onreset)
Set the value of the '
onreset ' attribute. |
void |
setOnsubmit(java.lang.String onsubmit)
Set the value of the '
onsubmit ' attribute. |
void |
setPath(java.lang.String path)
Unsupported for forms.
|
void |
setServletRelativeAction(java.lang.String servletRelativeAction)
Set the value of the '
action ' attribute through a value
that is to be appended to the current servlet path. |
void |
setTarget(java.lang.String target)
Set the value of the '
target ' attribute. |
private void |
writeHiddenFields(java.util.Map<java.lang.String,java.lang.String> hiddenFields)
Writes the given values as hidden fields.
|
protected int |
writeTagContent(TagWriter tagWriter)
Writes the opening part of the block '
form ' tag and exposes
the form object name in the javax.servlet.jsp.PageContext . |
getCssClass, getCssErrorClass, getCssStyle, getDir, getDynamicAttributes, getLang, getOnclick, getOndblclick, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getTabindex, getTitle, isValidDynamicAttribute, setCssClass, setCssStyle, setDir, setDynamicAttribute, setLang, setOnclick, setOndblclick, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setTabindex, setTitle, writeDefaultAttributes, writeOptionalAttributes
convertToDisplayString, getBindStatus, getBoundValue, getEditor, getId, getNestedPath, getPath, getPropertyEditor, getPropertyPath, processFieldValue, resolveId, setId
createTagWriter, doStartTagInternal, evaluate, getDisplayString, getDisplayString, isDefaultHtmlEscape, writeOptionalAttribute
htmlEscape, isHtmlEscape, isResponseEncodedHtmlEscape, setHtmlEscape
doCatch, doStartTag, getRequestContext
private static final java.lang.String DEFAULT_METHOD
public static final java.lang.String DEFAULT_COMMAND_NAME
private static final java.lang.String MODEL_ATTRIBUTE
modelAttribute
' settingpublic static final java.lang.String MODEL_ATTRIBUTE_VARIABLE_NAME
javax.servlet.jsp.PageContext
attribute under which the
form object name is exposed.private static final java.lang.String DEFAULT_METHOD_PARAM
_method
.private static final java.lang.String FORM_TAG
private static final java.lang.String INPUT_TAG
private static final java.lang.String ACTION_ATTRIBUTE
private static final java.lang.String METHOD_ATTRIBUTE
private static final java.lang.String TARGET_ATTRIBUTE
private static final java.lang.String ENCTYPE_ATTRIBUTE
private static final java.lang.String ACCEPT_CHARSET_ATTRIBUTE
private static final java.lang.String ONSUBMIT_ATTRIBUTE
private static final java.lang.String ONRESET_ATTRIBUTE
private static final java.lang.String AUTOCOMPLETE_ATTRIBUTE
private static final java.lang.String NAME_ATTRIBUTE
private static final java.lang.String VALUE_ATTRIBUTE
private static final java.lang.String TYPE_ATTRIBUTE
private TagWriter tagWriter
private java.lang.String modelAttribute
private java.lang.String name
private java.lang.String action
private java.lang.String servletRelativeAction
private java.lang.String method
private java.lang.String target
private java.lang.String enctype
private java.lang.String acceptCharset
private java.lang.String onsubmit
private java.lang.String onreset
private java.lang.String autocomplete
private java.lang.String methodParam
private java.lang.String previousNestedPath
public void setModelAttribute(java.lang.String modelAttribute)
May be a runtime expression.
protected java.lang.String getModelAttribute()
@Deprecated public void setCommandName(java.lang.String commandName)
setModelAttribute(java.lang.String)
May be a runtime expression.
setModelAttribute(java.lang.String)
@Deprecated protected java.lang.String getCommandName()
getModelAttribute()
getModelAttribute()
public void setName(java.lang.String name)
name
' attribute.
May be a runtime expression.
Name is not a valid attribute for form on XHTML 1.0. However, it is sometimes needed for backward compatibility.
protected java.lang.String getName() throws JspException
name
' attribute.getName
in class AbstractDataBoundFormElementTag
name
' attributeJspException
public void setAction(java.lang.String action)
action
' attribute.
May be a runtime expression.
protected java.lang.String getAction()
action
' attribute.public void setServletRelativeAction(java.lang.String servletRelativeAction)
action
' attribute through a value
that is to be appended to the current servlet path.
May be a runtime expression.
protected java.lang.String getServletRelativeAction()
action
' attribute.public void setMethod(java.lang.String method)
method
' attribute.
May be a runtime expression.
protected java.lang.String getMethod()
method
' attribute.public void setTarget(java.lang.String target)
target
' attribute.
May be a runtime expression.
public java.lang.String getTarget()
target
' attribute.public void setEnctype(java.lang.String enctype)
enctype
' attribute.
May be a runtime expression.
protected java.lang.String getEnctype()
enctype
' attribute.public void setAcceptCharset(java.lang.String acceptCharset)
acceptCharset
' attribute.
May be a runtime expression.
protected java.lang.String getAcceptCharset()
acceptCharset
' attribute.public void setOnsubmit(java.lang.String onsubmit)
onsubmit
' attribute.
May be a runtime expression.
protected java.lang.String getOnsubmit()
onsubmit
' attribute.public void setOnreset(java.lang.String onreset)
onreset
' attribute.
May be a runtime expression.
protected java.lang.String getOnreset()
onreset
' attribute.public void setAutocomplete(java.lang.String autocomplete)
autocomplete
' attribute.
May be a runtime expression.protected java.lang.String getAutocomplete()
autocomplete
' attribute.public void setMethodParam(java.lang.String methodParam)
protected java.lang.String getMethodParam()
@Deprecated protected java.lang.String getMethodParameter()
getMethodParam()
which is
a proper pairing for setMethodParam(String)
protected boolean isMethodBrowserSupported(java.lang.String method)
protected int writeTagContent(TagWriter tagWriter) throws JspException
form
' tag and exposes
the form object name in the javax.servlet.jsp.PageContext
.writeTagContent
in class AbstractFormTag
tagWriter
- the TagWriter
to which the form content is to be writtenjavax.servlet.jsp.tagext.Tag#EVAL_BODY_INCLUDE
JspException
private java.lang.String getHttpMethod()
private void assertHttpMethod(java.lang.String method)
protected java.lang.String autogenerateId() throws JspException
autogenerateId
in class AbstractDataBoundFormElementTag
JspException
protected java.lang.String resolveModelAttribute() throws JspException
Resolves
and returns the name of the form object.java.lang.IllegalArgumentException
- if the form object resolves to null
JspException
protected java.lang.String resolveAction() throws JspException
action
' attribute.
If the user configured an 'action
' value then the result of
evaluating this value is used. If the user configured an
'servletRelativeAction
' value then the value is prepended
with the context and servlet paths, and the result is used. Otherwise, the
originating URI
is used.
action
' attributeJspException
private java.lang.String processAction(java.lang.String action)
RequestDataValueProcessor
instance
if one is configured or otherwise returns the action unmodified.public int doEndTag() throws JspException
form
' block tag and removes the form object name
from the javax.servlet.jsp.PageContext
.JspException
private void writeHiddenFields(java.util.Map<java.lang.String,java.lang.String> hiddenFields) throws JspException
JspException
public void doFinally()
TagWriter
.doFinally
in class AbstractDataBoundFormElementTag
protected java.lang.String resolveCssClass() throws JspException
resolveCssClass
in class AbstractHtmlElementTag
JspException
public void setPath(java.lang.String path)
setPath
in class AbstractDataBoundFormElementTag
java.lang.UnsupportedOperationException
- alwayspublic void setCssErrorClass(java.lang.String cssErrorClass)
setCssErrorClass
in class AbstractHtmlElementTag
java.lang.UnsupportedOperationException
- always