net.sourceforge.stripes.tag
Class InputOptionsEnumerationTag

java.lang.Object
  extended by net.sourceforge.stripes.tag.StripesTagSupport
      extended by net.sourceforge.stripes.tag.HtmlTagSupport
          extended by net.sourceforge.stripes.tag.InputOptionsCollectionTag
              extended by net.sourceforge.stripes.tag.InputOptionsEnumerationTag
All Implemented Interfaces:
DynamicAttributes, JspTag, Tag

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.

Author:
Tim Fennell

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sourceforge.stripes.tag.InputOptionsCollectionTag
InputOptionsCollectionTag.Entry
 
Field Summary
 
Fields inherited from class net.sourceforge.stripes.tag.StripesTagSupport
pageContext, parentTag
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
InputOptionsEnumerationTag()
           
 
Method Summary
 int doStartTag()
          Attempts to instantiate the Class object representing the enum and fetch the values of the enum.
 String getEnum()
          Gets the enum class name set with setEnum().
 void setEnum(String name)
          Sets the fully qualified name of an enumeration class.
 
Methods inherited from class net.sourceforge.stripes.tag.InputOptionsCollectionTag
addEntry, addEntry, doEndTag, getCollection, getGroup, getLabel, getSort, getValue, setCollection, setGroup, setLabel, setSort, setValue
 
Methods inherited from class net.sourceforge.stripes.tag.HtmlTagSupport
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
 
Methods inherited from class net.sourceforge.stripes.tag.StripesTagSupport
getActionBeanType, getActionBeanUrl, getPageContext, getParent, getParentTag, getTagStack, popPageContextAttributes, pushPageContextAttributes, setPageContext, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, release, setPageContext, setParent
 

Constructor Detail

InputOptionsEnumerationTag

public InputOptionsEnumerationTag()
Method Detail

setEnum

public void setEnum(String name)
Sets the fully qualified name of an enumeration class.


getEnum

public String getEnum()
Gets the enum class name set with setEnum().


doStartTag

public int doStartTag()
               throws JspException
Attempts to instantiate the Class object representing the enum and fetch the values of the enum. Then generates an option per value using an instance of an InputOptionTag.

Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class InputOptionsCollectionTag
Returns:
SKIP_BODY in all cases.
Throws:
JspException - if the class name supplied is not a valid class, or cannot be cast to Class.


? Copyright 2005-2006, Stripes Development Team.