Class AbstractDataBoundFormElementTag

All Implemented Interfaces:
jakarta.servlet.jsp.tagext.IterationTag, jakarta.servlet.jsp.tagext.JspTag, jakarta.servlet.jsp.tagext.Tag, jakarta.servlet.jsp.tagext.TryCatchFinally, Serializable, EditorAwareTag
Direct Known Subclasses:
AbstractHtmlElementTag

public abstract class AbstractDataBoundFormElementTag extends AbstractFormTag implements EditorAwareTag
Base tag for all data-binding aware JSP form tags.

Provides the common path and id properties. Provides subclasses with utility methods for accessing the BindStatus of their bound value and also for interacting with the TagWriter.

Since:
2.0
Author:
Rob Harrop, Juergen Hoeller
See Also:
  • Field Details

  • Constructor Details

    • AbstractDataBoundFormElementTag

      public AbstractDataBoundFormElementTag()
  • Method Details

    • setPath

      public void setPath(String path)
      Set the property path from the form object. May be a runtime expression.
    • getPath

      protected final String getPath() throws jakarta.servlet.jsp.JspException
      Get the resolved property path for the form object.
      Throws:
      jakarta.servlet.jsp.JspException
    • setId

      public void setId(@Nullable String id)
      Set the value of the 'id' attribute.

      May be a runtime expression; defaults to the value of getName(). Note that the default value may not be valid for certain tags.

      Overrides:
      setId in class jakarta.servlet.jsp.tagext.TagSupport
    • getId

      public @Nullable String getId()
      Get the value of the 'id' attribute.
      Overrides:
      getId in class jakarta.servlet.jsp.tagext.TagSupport
    • writeDefaultAttributes

      protected void writeDefaultAttributes(TagWriter tagWriter) throws jakarta.servlet.jsp.JspException
      Writes the default set of attributes to the supplied TagWriter. Further, abstract subclasses should override this method to add in any additional default attributes but must remember to call the super method.

      Concrete subclasses should call this method when/if they want to render default attributes.

      Parameters:
      tagWriter - the TagWriter to which any attributes are to be written
      Throws:
      jakarta.servlet.jsp.JspException
    • resolveId

      protected @Nullable String resolveId() throws jakarta.servlet.jsp.JspException
      Determine the 'id' attribute value for this tag, autogenerating one if none specified.
      Throws:
      jakarta.servlet.jsp.JspException
      See Also:
    • autogenerateId

      protected @Nullable String autogenerateId() throws jakarta.servlet.jsp.JspException
      Autogenerate the 'id' attribute value for this tag.

      The default implementation simply delegates to getName(), deleting invalid characters (such as "[" or "]").

      Throws:
      jakarta.servlet.jsp.JspException
    • getName

      protected @Nullable String getName() throws jakarta.servlet.jsp.JspException
      Get the value for the HTML 'name' attribute.

      The default implementation simply delegates to getPropertyPath() to use the property path as the name. For the most part this is desirable as it links with the server-side expectation for data binding. However, some subclasses may wish to change the value of the 'name' attribute without changing the bind path.

      Returns:
      the value for the HTML 'name' attribute
      Throws:
      jakarta.servlet.jsp.JspException
    • getBindStatus

      protected BindStatus getBindStatus() throws jakarta.servlet.jsp.JspException
      Get the BindStatus for this tag.
      Throws:
      jakarta.servlet.jsp.JspException
    • getNestedPath

      protected @Nullable String getNestedPath()
      Get the value of the nested path that may have been exposed by the NestedPathTag.
    • getPropertyPath

      protected String getPropertyPath() throws jakarta.servlet.jsp.JspException
      Build the property path for this tag, including the nested path but not prefixed with the name of the form attribute.
      Throws:
      jakarta.servlet.jsp.JspException
      See Also:
    • getBoundValue

      protected final @Nullable Object getBoundValue() throws jakarta.servlet.jsp.JspException
      Get the bound value.
      Throws:
      jakarta.servlet.jsp.JspException
      See Also:
    • getPropertyEditor

      protected @Nullable PropertyEditor getPropertyEditor() throws jakarta.servlet.jsp.JspException
      Get the PropertyEditor, if any, in use for value bound to this tag.
      Throws:
      jakarta.servlet.jsp.JspException
    • getEditor

      public final @Nullable PropertyEditor getEditor() throws jakarta.servlet.jsp.JspException
      Exposes the PropertyEditor for EditorAwareTag.

      Use getPropertyEditor() for internal rendering purposes.

      Specified by:
      getEditor in interface EditorAwareTag
      Returns:
      the current PropertyEditor, or null if none
      Throws:
      jakarta.servlet.jsp.JspException - if resolving the editor failed
    • convertToDisplayString

      protected String convertToDisplayString(@Nullable Object value) throws jakarta.servlet.jsp.JspException
      Get a display String for the given value, converted by a PropertyEditor that the BindStatus may have registered for the value's Class.
      Throws:
      jakarta.servlet.jsp.JspException
    • processFieldValue

      protected final String processFieldValue(@Nullable String name, String value, String type)
      Process the given form field through a RequestDataValueProcessor instance if one is configured or otherwise returns the same value.
    • doFinally

      public void doFinally()
      Disposes of the BindStatus instance.
      Specified by:
      doFinally in interface jakarta.servlet.jsp.tagext.TryCatchFinally
      Overrides:
      doFinally in class RequestContextAwareTag