public class

FormTag

extends AbstractHtmlElementTag
java.lang.Object
   ↳ TagSupport
     ↳ org.springframework.web.servlet.tags.RequestContextAwareTag
       ↳ org.springframework.web.servlet.tags.HtmlEscapingAwareTag
         ↳ org.springframework.web.servlet.tags.form.AbstractFormTag
           ↳ org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
             ↳ org.springframework.web.servlet.tags.form.AbstractHtmlElementTag
               ↳ org.springframework.web.servlet.tags.form.FormTag

Class Overview

Databinding-aware JSP tag for rendering an HTML '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.

Summary

Constants
String DEFAULT_COMMAND_NAME The default attribute name: "command"
[Expand]
Inherited Constants
From class org.springframework.web.servlet.tags.form.AbstractHtmlElementTag
From class org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
From class org.springframework.web.servlet.tags.RequestContextAwareTag
Fields
public static final String MODEL_ATTRIBUTE_VARIABLE_NAME The name of the javax.servlet.jsp.PageContext attribute under which the form object name is exposed.
[Expand]
Inherited Fields
From class org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
From class org.springframework.web.servlet.tags.RequestContextAwareTag
Public Constructors
FormTag()
Public Methods
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.
String getTarget()
Get the value of the 'target' attribute.
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 Methods
String autogenerateId()
Autogenerated IDs correspond to the form object name.
String getAcceptCharset()
Get the value of the 'acceptCharset' attribute.
String getAction()
Get the value of the 'action' attribute.
String getAutocomplete()
Get the value of the 'autocomplete' attribute.
String getCommandName()
Get the name of the form attribute in the model.
String getEnctype()
Get the value of the 'enctype' attribute.
String getMethod()
Get the value of the 'method' attribute.
String getMethodParameter()
Get the name of the request param for non-browser supported HTTP methods.
String getModelAttribute()
Get the name of the form attribute in the model.
String getName()
Get the value of the 'name' attribute.
String getOnreset()
Get the value of the 'onreset' attribute.
String getOnsubmit()
Get the value of the 'onsubmit' attribute.
boolean isMethodBrowserSupported(String method)
Determine if the HTTP method is supported by browsers (i.e.
String resolveAction()
Resolve the value of the 'action' attribute.
String resolveCssClass()
Override resolve CSS class since error class is not supported.
String resolveModelAttribute()
Resolves and returns the name of the form object.
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.
[Expand]
Inherited Methods
From class org.springframework.web.servlet.tags.form.AbstractHtmlElementTag
From class org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
From class org.springframework.web.servlet.tags.form.AbstractFormTag
From class org.springframework.web.servlet.tags.HtmlEscapingAwareTag
From class org.springframework.web.servlet.tags.RequestContextAwareTag
From class java.lang.Object
From interface org.springframework.web.servlet.tags.EditorAwareTag

Constants

public static final String DEFAULT_COMMAND_NAME

The default attribute name: "command"

Constant Value: "command"

Fields

public static final String MODEL_ATTRIBUTE_VARIABLE_NAME

The name of the javax.servlet.jsp.PageContext attribute under which the form object name is exposed.

Public Constructors

public FormTag ()

Public Methods

public int doEndTag ()

Closes the 'form' block tag and removes the form object name from the javax.servlet.jsp.PageContext.

Throws
JspException

public void doFinally ()

Clears the stored TagWriter.

public String getTarget ()

Get the value of the 'target' attribute.

public void setAcceptCharset (String acceptCharset)

Set the value of the 'acceptCharset' attribute.

May be a runtime expression.

public void setAction (String action)

Set the value of the 'action' attribute.

May be a runtime expression.

public void setAutocomplete (String autocomplete)

Set the value of the 'autocomplete' attribute. May be a runtime expression.

public void setCommandName (String commandName)

Set the name of the form attribute in the model.

May be a runtime expression.

public void setCssErrorClass (String cssErrorClass)

Unsupported for forms.

public void setEnctype (String enctype)

Set the value of the 'enctype' attribute.

May be a runtime expression.

public void setMethod (String method)

Set the value of the 'method' attribute.

May be a runtime expression.

public void setMethodParam (String methodParam)

Set the name of the request param for non-browser supported HTTP methods.

public void setModelAttribute (String modelAttribute)

Set the name of the form attribute in the model.

May be a runtime expression.

public void setName (String name)

Set the value of the '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.

public void setOnreset (String onreset)

Set the value of the 'onreset' attribute.

May be a runtime expression.

public void setOnsubmit (String onsubmit)

Set the value of the 'onsubmit' attribute.

May be a runtime expression.

public void setPath (String path)

Unsupported for forms.

public void setTarget (String target)

Set the value of the 'target' attribute.

May be a runtime expression.

Protected Methods

protected String autogenerateId ()

Autogenerated IDs correspond to the form object name.

Throws
JspException

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.

Returns
  • the value for the HTML 'name' attribute
Throws
JspException

protected String getOnreset ()

Get the value of the 'onreset' attribute.

protected String getOnsubmit ()

Get the value of the 'onsubmit' attribute.

protected boolean isMethodBrowserSupported (String method)

Determine if the HTTP method is supported by browsers (i.e. GET or POST).

protected String resolveAction ()

Resolve the value of the 'action' attribute.

If the user configured an 'action' value then the result of evaluating this value is used. Otherwise, the originating URI is used.

Returns
  • the value that is to be used for the 'action' attribute
Throws
JspException

protected String resolveCssClass ()

Override resolve CSS class since error class is not supported.

Throws
JspException

protected String resolveModelAttribute ()

Resolves and returns the name of the form object.

Throws
IllegalArgumentException if the form object resolves to null
JspException

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.

Parameters
tagWriter the TagWriter to which the form content is to be written
Returns
  • javax.servlet.jsp.tagext.Tag#EVAL_BODY_INCLUDE
Throws
JspException