public class InputOptionsEnumerationTag extends InputOptionsCollectionTag
Writes a set of <option value="foo">bar</option> tags to the page based on the values of a enum. Each value in the enum is represented by a single option tag on the page. The options will be generated in ordinal value order (i.e. the order they are declared in the enum).
The label (the value the user sees) is generated in one of three ways: by looking up a localized value, by using the property named by the 'label' tag attribute if it is supplied and lastly by toString()'ing the enumeration value. For example the following tag:
<stripes:options-enumeration enum="net.kitty.EyeColor" label="description"/>when generating the option for the value
EyeColor.BLUE
will look for a label in the
following order:
If the class specified does not exist, or does not specify a Java 1.5 enum then a JspException will be raised.
All attributes of the tag, other than enum and label, are passed directly through to the InputOptionTag which is used to generate the individual HTML options tags. As a result the InputOptionsEnumerationTag will exhibit the same re-population/selection behaviour as the regular options tag.
Since the tag has no use for one it does not allow a body.
InputOptionsCollectionTag.Entry
pageContext, parentTag
Constructor and Description |
---|
InputOptionsEnumerationTag() |
Modifier and Type | Method and Description |
---|---|
int |
doStartTag()
Attempts to instantiate the Class object representing the enum and fetch the values of the
enum.
|
java.lang.String |
getEnum()
Gets the enum class name set with setEnum().
|
void |
setEnum(java.lang.String name)
Sets the fully qualified name of an enumeration class.
|
addEntry, addEntry, doEndTag, getCollection, getGroup, getLabel, getSort, getValue, setCollection, setGroup, setLabel, setSort, setValue
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 setEnum(java.lang.String name)
public java.lang.String getEnum()
public int doStartTag() throws javax.servlet.jsp.JspException
doStartTag
in interface javax.servlet.jsp.tagext.Tag
doStartTag
in class InputOptionsCollectionTag
javax.servlet.jsp.JspException
- if the class name supplied is not a valid class, or cannot be cast
to Class? Copyright 2005-2006, Stripes Development Team.