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.
The default value for the "modelAttribute"
property is 'command
' which corresponds to the default name
when using the
SimpleFormController
.
SimpleFormController
,
Serialized FormModifier and Type | Field and Description |
---|---|
static String |
DEFAULT_COMMAND_NAME
The default attribute name: "command"
|
static String |
MODEL_ATTRIBUTE_VARIABLE_NAME
The name of the
PageContext attribute under which the
form object name is exposed. |
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
COMMAND_NAME_VARIABLE_NAME, NESTED_PATH_VARIABLE_NAME
logger, REQUEST_CONTEXT_PAGE_ATTRIBUTE
pageContext
EVAL_BODY_AGAIN
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
Constructor and Description |
---|
FormTag() |
Modifier and Type | Method and Description |
---|---|
protected 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 PageContext . |
void |
doFinally()
Clears the stored
TagWriter . |
protected String |
getAcceptCharset()
Get the value of the '
acceptCharset ' attribute. |
protected String |
getAction()
Get the value of the '
action ' attribute. |
protected String |
getAutocomplete()
Get the value of the '
autocomplete ' attribute. |
protected String |
getCommandName()
Get the name of the form attribute in the model.
|
protected String |
getEnctype()
Get the value of the '
enctype ' attribute. |
protected String |
getMethod()
Get the value of the '
method ' attribute. |
protected String |
getMethodParameter()
Get the name of the request param for non-browser supported HTTP methods.
|
protected String |
getModelAttribute()
Get the name of the form attribute in the model.
|
protected String |
getName()
Get the value of the '
name ' attribute. |
protected String |
getOnreset()
Get the value of the '
onreset ' attribute. |
protected String |
getOnsubmit()
Get the value of the '
onsubmit ' attribute. |
String |
getTarget()
Get the value of the '
target ' attribute. |
protected boolean |
isMethodBrowserSupported(String method)
Determine if the HTTP method is supported by browsers (i.e.
|
protected String |
resolveAction()
Resolve the value of the '
action ' attribute. |
protected String |
resolveCssClass()
Override resolve CSS class since error class is not supported.
|
protected String |
resolveModelAttribute()
Resolves and returns the name of the form object. |
void |
setAcceptCharset(String acceptCharset)
Set the value of the '
acceptCharset ' attribute. |
void |
setAction(String action)
Set the value of the '
action ' attribute. |
void |
setAutocomplete(String autocomplete)
Set the value of the '
autocomplete ' attribute. |
void |
setCommandName(String commandName)
Set the name of the form attribute in the model.
|
void |
setCssErrorClass(String cssErrorClass)
Unsupported for forms.
|
void |
setEnctype(String enctype)
Set the value of the '
enctype ' attribute. |
void |
setMethod(String method)
Set the value of the '
method ' attribute. |
void |
setMethodParam(String methodParam)
Set the name of the request param for non-browser supported HTTP methods.
|
void |
setModelAttribute(String modelAttribute)
Set the name of the form attribute in the model.
|
void |
setName(String name)
Set the value of the '
name ' attribute. |
void |
setOnreset(String onreset)
Set the value of the '
onreset ' attribute. |
void |
setOnsubmit(String onsubmit)
Set the value of the '
onsubmit ' attribute. |
void |
setPath(String path)
Unsupported for forms.
|
void |
setTarget(String target)
Set the value of the '
target ' attribute. |
protected int |
writeTagContent(TagWriter tagWriter)
Writes the opening part of the block '
form ' tag and exposes
the form object name in the 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, evaluateBoolean, getDisplayString, getDisplayString, isDefaultHtmlEscape, writeOptionalAttribute
isHtmlEscape, setHtmlEscape
doCatch, doStartTag, getRequestContext
doAfterBody, findAncestorWithClass, getParent, getValue, getValues, release, removeValue, setPageContext, setParent, setValue
public static final String DEFAULT_COMMAND_NAME
public static final String MODEL_ATTRIBUTE_VARIABLE_NAME
PageContext
attribute under which the
form object name is exposed.public void setModelAttribute(String modelAttribute)
May be a runtime expression.
protected String getModelAttribute()
public void setCommandName(String commandName)
May be a runtime expression.
setModelAttribute(java.lang.String)
protected String getCommandName()
getModelAttribute()
public void setName(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 String getName() throws JspException
name
' attribute.getName
in class AbstractDataBoundFormElementTag
name
' attributeJspException
public void setAction(String action)
action
' attribute.
May be a runtime expression.
protected String getAction()
action
' attribute.public void setMethod(String method)
method
' attribute.
May be a runtime expression.
protected String getMethod()
method
' attribute.public void setTarget(String target)
target
' attribute.
May be a runtime expression.
public String getTarget()
target
' attribute.public void setEnctype(String enctype)
enctype
' attribute.
May be a runtime expression.
protected String getEnctype()
enctype
' attribute.public void setAcceptCharset(String acceptCharset)
acceptCharset
' attribute.
May be a runtime expression.
protected String getAcceptCharset()
acceptCharset
' attribute.public void setOnsubmit(String onsubmit)
onsubmit
' attribute.
May be a runtime expression.
protected String getOnsubmit()
onsubmit
' attribute.public void setOnreset(String onreset)
onreset
' attribute.
May be a runtime expression.
protected String getOnreset()
onreset
' attribute.public void setAutocomplete(String autocomplete)
autocomplete
' attribute.
May be a runtime expression.protected String getAutocomplete()
autocomplete
' attribute.public void setMethodParam(String methodParam)
protected String getMethodParameter()
protected boolean isMethodBrowserSupported(String method)
protected int writeTagContent(TagWriter tagWriter) throws JspException
form
' tag and exposes
the form object name in the PageContext
.writeTagContent
in class AbstractFormTag
tagWriter
- the TagWriter
to which the form content is to be writtenTag.EVAL_BODY_INCLUDE
JspException
protected String autogenerateId() throws JspException
autogenerateId
in class AbstractDataBoundFormElementTag
JspException
protected String resolveModelAttribute() throws JspException
Resolves
and returns the name of the form object.IllegalArgumentException
- if the form object resolves to null
JspException
protected String resolveAction() throws JspException
action
' attribute.
If the user configured an 'action
' value then
the result of evaluating this value is used. Otherwise, the
originating URI
is used.
action
' attributeJspException
public int doEndTag() throws JspException
form
' block tag and removes the form object name
from the PageContext
.doEndTag
in interface Tag
doEndTag
in class TagSupport
JspException
public void doFinally()
TagWriter
.doFinally
in interface TryCatchFinally
doFinally
in class AbstractDataBoundFormElementTag
protected String resolveCssClass() throws JspException
resolveCssClass
in class AbstractHtmlElementTag
JspException
public void setPath(String path)
setPath
in class AbstractDataBoundFormElementTag
UnsupportedOperationException
- alwayspublic void setCssErrorClass(String cssErrorClass)
setCssErrorClass
in class AbstractHtmlElementTag
UnsupportedOperationException
- always