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

java.lang.Object
  extended by 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:
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 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, Juergen Hoeller

Field Summary
private  BindStatus bindStatus
          The BindStatus of this tag.
static java.lang.String COMMAND_NAME_VARIABLE_NAME
          Deprecated. as of Spring 2.5, in favor of FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME
private  java.lang.String id
          The value of the 'id' attribute.
protected static java.lang.String NESTED_PATH_VARIABLE_NAME
          Name of the exposed path variable within the scope of this tag: "nestedPath".
private  java.lang.String path
          The property path from the form object.
 
Fields inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
logger, REQUEST_CONTEXT_PAGE_ATTRIBUTE
 
Constructor Summary
AbstractDataBoundFormElementTag()
           
 
Method Summary
protected  java.lang.String autogenerateId()
          Autogenerate the 'id' attribute value for this tag.
protected  java.lang.String convertToDisplayString(java.lang.Object value)
          Get a display String for the given value, converted by a PropertyEditor that the BindStatus may have registered for the value's Class.
 void doFinally()
          Disposes of the BindStatus instance.
protected  BindStatus getBindStatus()
          Get the BindStatus for this tag.
protected  java.lang.Object getBoundValue()
          Get the bound value.
 java.beans.PropertyEditor getEditor()
          Exposes the PropertyEditor for EditorAwareTag.
 java.lang.String getId()
          Get the value of the 'id' attribute.
protected  java.lang.String getName()
          Get the value for the HTML 'name' attribute.
protected  java.lang.String getNestedPath()
          Get the value of the nested path that may have been exposed by the NestedPathTag.
protected  java.lang.String getPath()
          Get the resolved property path for the form object.
protected  java.beans.PropertyEditor getPropertyEditor()
          Get the PropertyEditor, if any, in use for value bound to this tag.
protected  java.lang.String getPropertyPath()
          Build the property path for this tag, including the nested path but not prefixed with the name of the form attribute.
protected  java.lang.String processFieldValue(java.lang.String name, java.lang.String value, java.lang.String type)
          Process the given form field through a RequestDataValueProcessor instance if one is configured or otherwise returns the same value.
protected  java.lang.String resolveId()
          Determine the 'id' attribute value for this tag, autogenerating one if none specified.
 void setId(java.lang.String id)
          Set the value of the 'id' attribute.
 void setPath(java.lang.String path)
          Set the property path from the form 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, evaluateBoolean, getDisplayString, getDisplayString, isDefaultHtmlEscape, 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NESTED_PATH_VARIABLE_NAME

protected static final java.lang.String NESTED_PATH_VARIABLE_NAME
Name of the exposed path variable within the scope of this tag: "nestedPath". Same value as NestedPathTag.NESTED_PATH_VARIABLE_NAME.

See Also:
Constant Field Values

COMMAND_NAME_VARIABLE_NAME

@Deprecated
public static final java.lang.String COMMAND_NAME_VARIABLE_NAME
Deprecated. as of Spring 2.5, in favor of FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME
The name of the javax.servlet.jsp.PageContext attribute under which the command object name is exposed.


path

private java.lang.String path
The property path from the form object.


id

private java.lang.String id
The value of the 'id' attribute.


bindStatus

private BindStatus bindStatus
The BindStatus of this tag.

Constructor Detail

AbstractDataBoundFormElementTag

public AbstractDataBoundFormElementTag()
Method Detail

setPath

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


getPath

protected final java.lang.String getPath()
                                  throws JspException
Get the resolved property path for the form object.

Throws:
JspException

setId

public void setId(java.lang.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.


getId

public java.lang.String getId()
Get the value of the 'id' attribute.


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

resolveId

protected java.lang.String resolveId()
                              throws JspException
Determine the 'id' attribute value for this tag, autogenerating one if none specified.

Throws:
JspException
See Also:
getId(), autogenerateId()

autogenerateId

protected java.lang.String autogenerateId()
                                   throws JspException
Autogenerate the 'id' attribute value for this tag.

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

Throws:
JspException

getName

protected java.lang.String getName()
                            throws 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:
JspException

getBindStatus

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

Throws:
JspException

getNestedPath

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


getPropertyPath

protected java.lang.String getPropertyPath()
                                    throws JspException
Build the property path for this tag, including the nested path but not prefixed with the name of the form attribute.

Throws:
JspException
See Also:
getNestedPath(), getPath()

getBoundValue

protected final java.lang.Object getBoundValue()
                                        throws JspException
Get the bound value.

Throws:
JspException
See Also:
getBindStatus()

getPropertyEditor

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

Throws:
JspException

getEditor

public final java.beans.PropertyEditor getEditor()
                                          throws 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:
JspException - if resolving the editor failed

convertToDisplayString

protected java.lang.String convertToDisplayString(java.lang.Object value)
                                           throws 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:
JspException

processFieldValue

protected final java.lang.String processFieldValue(java.lang.String name,
                                                   java.lang.String value,
                                                   java.lang.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.

Overrides:
doFinally in class RequestContextAwareTag