The Spring Framework

org.springframework.web.servlet.tags.form
Class AbstractDataBoundFormElementTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by org.springframework.web.servlet.tags.RequestContextAwareTag
          extended by org.springframework.web.servlet.tags.HtmlEscapingAwareTag
              extended by org.springframework.web.servlet.tags.form.AbstractFormTag
                  extended by org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
All Implemented Interfaces:
Serializable, IterationTag, JspTag, Tag, TryCatchFinally
Direct Known Subclasses:
AbstractHtmlElementTag, HiddenInputTag

public abstract class AbstractDataBoundFormElementTag
extends AbstractFormTag

Base tag for all data-binding aware JSP form tags.

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

Since:
2.0
Author:
Rob Harrop
See Also:
Serialized Form

Field Summary
static String ID_ATTRIBUTE
          The 'id' attribute of the rendered HTML tag.
 
Fields inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
logger, REQUEST_CONTEXT_PAGE_ATTRIBUTE
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
AbstractDataBoundFormElementTag()
           
 
Method Summary
protected  String autogenerateId()
          Autogenerate the 'id' attribute value for this tag.
 void doFinally()
          Disposes of the BindStatus instance.
protected  BindStatus getBindStatus()
          Gets the BindStatus for this tag.
protected  Object getBoundValue()
          Gets the bound value.
 String getId()
          Gets the value of the 'id' attribute.
protected  String getName()
          Gets the value for the HTML 'name' attribute.
protected  String getNestedPath()
          Gets the value of the nested path that may have been exposed by the NestedPathTag.
protected  String getPath()
          Gets the resolved property path from the command object.
protected  PropertyEditor getPropertyEditor()
          Gets the PropertyEditor, if any, in use for value bound to this tag.
 void setId(String id)
          Sets the value of the 'id' attribute.
 void setPath(String path)
          Sets the property path from the command object.
protected  void writeDefaultAttributes(TagWriter tagWriter)
          Writes the default set of attributes to the supplied TagWriter.
 
Methods inherited from class org.springframework.web.servlet.tags.form.AbstractFormTag
createTagWriter, doStartTagInternal, evaluate, getDisplayString, getDisplayString, writeOptionalAttribute, writeTagContent
 
Methods inherited from class org.springframework.web.servlet.tags.HtmlEscapingAwareTag
isHtmlEscape, setHtmlEscape
 
Methods inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
doCatch, doStartTag, getRequestContext
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, findAncestorWithClass, getParent, getValue, getValues, release, removeValue, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_ATTRIBUTE

public static final String ID_ATTRIBUTE
The 'id' attribute of the rendered HTML tag.

See Also:
Constant Field Values
Constructor Detail

AbstractDataBoundFormElementTag

public AbstractDataBoundFormElementTag()
Method Detail

setPath

public void setPath(String path)
Sets the property path from the command object. May be a runtime expression. Required.

Throws:
IllegalArgumentException - if the supplied path is null or composed wholly of whitespace

setId

public void setId(String id)
Sets the value of the 'id' attribute.

Defaults to the value of getName(); may be a runtime expression.

Note that the default value may not be valid for certain tags.

Overrides:
setId in class TagSupport
Parameters:
id - the value of the 'id' attribute

getId

public String getId()
Gets the value of the 'id' attribute.

May be a runtime expression.

Overrides:
getId in class TagSupport
Returns:
the value of the 'id' attribute

getPath

protected final String getPath()
                        throws JspException
Gets the resolved property path from the command object.

Throws:
JspException

writeDefaultAttributes

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

Concrete sub-classes 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:
JspException

autogenerateId

protected String autogenerateId()
                         throws JspException
Autogenerate the 'id' attribute value for this tag. The default implementation simply delegates to getName().

Throws:
JspException

getName

protected String getName()
                  throws JspException
Gets the value for the HTML 'name' attribute.

The default implementation simply delegates to getNestedPath() and getPath() to use the property path as the name. For the most part this is desirable as it links with the server-side expectation for databinding. 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:
JspException

getBoundValue

protected final Object getBoundValue()
                              throws JspException
Gets the bound value.

Throws:
JspException
See Also:
getBindStatus()

getPropertyEditor

protected PropertyEditor getPropertyEditor()
                                    throws JspException
Gets the PropertyEditor, if any, in use for value bound to this tag.

Throws:
JspException

getBindStatus

protected BindStatus getBindStatus()
                            throws JspException
Gets the BindStatus for this tag.

Throws:
JspException

getNestedPath

protected String getNestedPath()
Gets the value of the nested path that may have been exposed by the NestedPathTag.


doFinally

public void doFinally()
Disposes of the BindStatus instance.

Specified by:
doFinally in interface TryCatchFinally
Overrides:
doFinally in class RequestContextAwareTag

The Spring Framework

Copyright © 2002-2006 The Spring Framework.