public class InputLabelTag extends InputTagSupport implements javax.servlet.jsp.tagext.BodyTag
Tag handler for a tag that produces an HTML label tag which is capable of looking up
localized field names and formatting the label when validation errors exist. The field being
labeled is identified using either the name
attribute (preferred) or the
for
attribute. If the name
attribute is supplied this will always be used as
the lookup key (optionally pre-pended with the form's action path). If the name
field
is not supplied, the tag will fall back to using the value supplied for the for
attribute. This is done because the for
attribute is used by HTML as a reference to the
id
of the input being labeled. In the case where the id is equal to the field name
it is unnecessary to specify a name
attribute for the label tag. In cases where the
field name (or other localized resource name) does not match an HTML ID, the name
attribute must be used.
The value used for the label is the localized field name if one exists. Localized field
names are looked up in the field name resource bundle first using formActionPath.fieldName
,
and then (if no value is found) using just fieldName
. If no localized String can be found
then the body of the label tag is used. If no body is supplied then a warning String will be used
instead!
errorRenderer, fieldErrors
pageContext, parentTag
Constructor and Description |
---|
InputLabelTag() |
Modifier and Type | Method and Description |
---|---|
int |
doAfterBody()
Does nothing.
|
int |
doEndInputTag()
Performs the main work of the tag as described in the class level javadoc.
|
void |
doInitBody()
Does nothing.
|
int |
doStartInputTag()
Does nothing.
|
java.lang.String |
getFor()
Gets the HTML ID of the field for which this is a label.
|
protected void |
loadErrors()
Wraps the parent loadErrors() to suppress exceptions when the label is outside of a
stripes form tag.
|
protected void |
registerWithParentForm()
Overridden to do nothing, since a label isn't really a form field.
|
void |
setFor(java.lang.String forId)
Sets the HTML ID of the field for which this is a label.
|
void |
setName(java.lang.String name)
Sets the name of the form element/label to be rendered.
|
doCatch, doEndTag, doFinally, doStartTag, format, format, getActionBean, getDisabled, getFieldErrors, getFormatPattern, getFormatType, getLocalizedFieldName, getLocalizedFieldName, getName, getOverrideValueOrValues, getParentFormTag, getReadonly, getSingleOverrideValue, getSize, getValidationMetadata, getValueOnPage, hasErrors, isItemSelected, makeFocused, setDisabled, setFocus, setFormatPattern, setFormatType, setReadonly, setSize
evaluateExpression, get, getAccesskey, getAttributes, getBodyContent, getBodyContentAsString, getCssClass, getDir, getId, getLang, getOnblur, getOnchange, getOnclick, getOndblclick, getOnfocus, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnselect, getStyle, getTabindex, getTitle, release, set, setAccesskey, setBodyContent, setClass, setCssClass, setDir, setDynamicAttribute, setId, setLang, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setStyle, setTabindex, setTitle, toString, writeAttributes, writeCloseTag, writeOpenTag, writeSingletonTag
getActionBeanType, getActionBeanUrl, getPageContext, getParent, getParentTag, getTagStack, popPageContextAttributes, pushPageContextAttributes, setPageContext, setParent
public void setFor(java.lang.String forId)
public java.lang.String getFor()
public void setName(java.lang.String name)
setName
in class InputTagSupport
public int doStartInputTag() throws javax.servlet.jsp.JspException
doStartInputTag
in class InputTagSupport
javax.servlet.jsp.JspException
public void doInitBody() throws javax.servlet.jsp.JspException
doInitBody
in interface javax.servlet.jsp.tagext.BodyTag
javax.servlet.jsp.JspException
public int doAfterBody() throws javax.servlet.jsp.JspException
doAfterBody
in interface javax.servlet.jsp.tagext.IterationTag
javax.servlet.jsp.JspException
public int doEndInputTag() throws javax.servlet.jsp.JspException
doEndInputTag
in class InputTagSupport
javax.servlet.jsp.JspException
- if an IOException is encountered writing to the output stream.protected void registerWithParentForm() throws StripesJspException
registerWithParentForm
in class InputTagSupport
StripesJspException
- if the parent form tag is not foundprotected void loadErrors()
loadErrors
in class InputTagSupport
? Copyright 2005-2006, Stripes Development Team.