Class AbstractFormTag
java.lang.Object
jakarta.servlet.jsp.tagext.TagSupport
org.springframework.web.servlet.tags.RequestContextAwareTag
org.springframework.web.servlet.tags.HtmlEscapingAwareTag
org.springframework.web.servlet.tags.form.AbstractFormTag
- All Implemented Interfaces:
IterationTag,JspTag,Tag,TryCatchFinally,Serializable
- Direct Known Subclasses:
AbstractDataBoundFormElementTag
Base class for all JSP form tags. Provides utility methods for
null-safe EL evaluation and for accessing and working with a
TagWriter.
Subclasses should implement the writeTagContent(TagWriter) to perform
actual tag rendering.
Subclasses (or test classes) can override the createTagWriter() method to
redirect output to a Writer other than the JspWriter
associated with the current PageContext.
- Since:
- 2.0
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
logger, REQUEST_CONTEXT_PAGE_ATTRIBUTEFields inherited from class jakarta.servlet.jsp.tagext.TagSupport
id, pageContextFields inherited from interface jakarta.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAINFields inherited from interface jakarta.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected TagWriterCreate theTagWriterwhich all output will be written to.protected final intProvide a simple template method that callscreateTagWriter()and passes the createdTagWriterto thewriteTagContent(TagWriter)method.protected ObjectEvaluate the supplied value for the supplied attribute name.protected StringgetDisplayString(Object value) Get the display value of the suppliedObject, HTML escaped as required.protected StringgetDisplayString(Object value, PropertyEditor propertyEditor) Get the display value of the suppliedObject, HTML escaped as required.protected booleanOverridden to default totruein case of no explicit default given.protected final voidwriteOptionalAttribute(TagWriter tagWriter, String attributeName, String value) Optionally writes the supplied value under the supplied attribute name into the suppliedTagWriter.protected abstract intwriteTagContent(TagWriter tagWriter) Subclasses should implement this method to perform tag content rendering.Methods inherited from class org.springframework.web.servlet.tags.HtmlEscapingAwareTag
htmlEscape, isHtmlEscape, isResponseEncodedHtmlEscape, setHtmlEscapeMethods inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
doCatch, doFinally, doStartTag, getRequestContextMethods inherited from class jakarta.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
-
Constructor Details
-
AbstractFormTag
public AbstractFormTag()
-
-
Method Details
-
evaluate
@Nullable protected Object evaluate(String attributeName, @Nullable Object value) throws JspException Evaluate the supplied value for the supplied attribute name.The default implementation simply returns the given value as-is.
- Throws:
JspException
-
writeOptionalAttribute
protected final void writeOptionalAttribute(TagWriter tagWriter, String attributeName, @Nullable String value) throws JspException Optionally writes the supplied value under the supplied attribute name into the suppliedTagWriter. In this case, the supplied value isevaluatedfirst and then theString representationis written as the attribute value. If the resultantStringrepresentation isnullor empty, no attribute is written.- Throws:
JspException- See Also:
-
createTagWriter
Create theTagWriterwhich all output will be written to. By default, theTagWriterwrites its output to theJspWriterfor the currentPageContext. Subclasses may choose to change theWriterto which output is actually written. -
doStartTagInternal
Provide a simple template method that callscreateTagWriter()and passes the createdTagWriterto thewriteTagContent(TagWriter)method.- Specified by:
doStartTagInternalin classRequestContextAwareTag- Returns:
- the value returned by
writeTagContent(TagWriter) - Throws:
Exception- any exception, any checked one other than a JspException gets wrapped in a JspException by doStartTag- See Also:
-
getDisplayString
Get the display value of the suppliedObject, HTML escaped as required. This version is notPropertyEditor-aware. -
getDisplayString
Get the display value of the suppliedObject, HTML escaped as required. If the supplied value is not aStringand the suppliedPropertyEditoris not null then thePropertyEditoris used to obtain the display value. -
isDefaultHtmlEscape
protected boolean isDefaultHtmlEscape()Overridden to default totruein case of no explicit default given.- Overrides:
isDefaultHtmlEscapein classHtmlEscapingAwareTag- See Also:
-
writeTagContent
Subclasses should implement this method to perform tag content rendering.- Returns:
- valid tag render instruction as per
Tag.doStartTag(). - Throws:
JspException
-