org.apache.beehive.netui.tags.html
Class Select

Object
  extended by TagSupport
      extended by BodyTagSupport
          extended by AbstractClassicTag
              extended by HtmlBaseTag
                  extended by HtmlFocusBaseTag
                      extended by HtmlDataSourceTag
                          extended by HtmlDefaultableDataSourceTag
                              extended by HtmlOptionsDataSourceTag
                                  extended by Select
All Implemented Interfaces:
Serializable, BodyTag, IterationTag, JspTag, Tag, IDataAccessProvider, HtmlConstants, IFormattable, IAttributeConsumer, IHtmlAttrs, IHtmlCore, IHtmlEvents, IHtmlI18n, INetuiTag

public class Select
extends HtmlOptionsDataSourceTag
implements IDataAccessProvider, IFormattable

Renders a select containing a set of SelectOptions. Select binds to an Iterator of Strings. If Select uses any Format tags, it must have those tags come before any nested SelectOption tags.

See Also:
Serialized Form
Example
The following sample uses the optionsDataSource attribute to reference a dynamically generated dropdown list.
    <netui:select dataSource="actionForm.selectedOption"
                  optionsDataSource="${actionForm.itemOptions}" />
 

Assume that the optionsDataSource attribute refers to a java.util.Map object. The Map object will be rendered as a series of <option> tags. HTML that is similar to the following will be rendered in the browser:

    <select name="wlw-select_key:{actionForm.itemOptions}">
        <option value="633">Aurora Bridge</option>
        <option value="631">FA-18 fighter jet</option>
        <option value="635">Space Needle</option>
        <option value="642">Thin Mints</option>
              ...
    </select>

Nested Class Summary
static class Select.RepeatingStages
          This enum defines stages through the possible option values.
static class Select.SelectPrefixHandler
           
 
Field Summary
static String NULL_VALUE
          Default value of the options value attribute.
 
Fields inherited from class HtmlOptionsDataSourceTag
_optionsDataSource
 
Fields inherited from class HtmlDefaultableDataSourceTag
_defaultValue
 
Fields inherited from class HtmlDataSourceTag
_dataSource
 
Fields inherited from class AbstractClassicTag
DefaultNamingChain, EMPTY_STRING, NETUI_UNIQUE_CNT
 
Fields inherited from class BodyTagSupport
bodyContent
 
Fields inherited from class TagSupport
id, pageContext
 
Fields inherited from interface HtmlConstants
ABBR, ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, AREA, AXIS, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, BUTTON, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COLSPAN, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEADERS, HEIGHT, HREF, HREFLANG, HSPACE, HTML, ID, IMAGE, INPUT, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, INPUT_PASSWORD, INPUT_RADIO, INPUT_RESET, INPUT_SUBMIT, INPUT_TEXT, ISMAP, LABEL, LANG, LANGUAGE, LINK, LONGDESC, MAXLENGTH, METHOD, NAME, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONLOAD, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONRESET, ONSELECT, ONSUBMIT, ONUNLOAD, OPTION, READONLY, REL, REV, ROWS, ROWSPAN, RULES, SCOPE, SCRIPT, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TBODY, TD, TEXT, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH
 
Fields inherited from interface BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
Select()
           
 
Method Summary
 void addFormatter(FormatTag.Formatter formatter)
          Adds a FormatTag.Formatter to the Select's set of formatters
 void addOptionToList(String value)
           
 int doAfterBody()
          Save any body content of this tag, which will generally be the option(s) representing the values displayed to the user.
 int doEndTag()
          Render the end of this select.
 int doStartTag()
          Render the beginning of this select.
protected  Object evaluateDefaultValue()
          Evaluate the defaultValues
protected  Object evaluateOptionsDataSource()
          This method will return the object representing the optionsDataSource.
 void formatterHasError()
          Indicate that a formatter has reported an error so the formatter should output it's body text.
 String formatText(Object text)
          Apply the Select's set of formatters to the given text
 int getCurrentIndex()
          Get the current index in this iteration.
 Object getCurrentItem()
          Get the current data item in this IDataAccessProvider.
 Object getCurrentMetadata()
          Get a metadata object for the current item.
 String getDataSource()
          Get the expression that references the data item to which the IDataAccessProvider is bound.
protected  List getNamingChain()
          Return an ArrayList which represents a chain of INameInterceptor objects.
 Object getOptionsDataSource()
          Gets the options datasource value (an expression).
 IDataAccessProvider getProviderParent()
          Get the parent IDataAccessProvider of a IDataAccessProvider.
 Select.RepeatingStages getRepeatingStage()
          Return the enum value of the currently repeating stage.
protected  AbstractHtmlState getState()
          This method will return the state associated with the tag.
 String getTagName()
          Return the name of the Tag.
 boolean isDataSourceStage()
          Boolean indicating that we are processing the dataSource.
 boolean isDefaultStage()
          Boolean indicating that we are processing the defaultValue.
 boolean isMatched(String value)
          Does the specified value match one of those we are looking for?
 boolean isNullStage()
          Boolean indicating that we are processing the defined null value.
 boolean isOptionStage()
          Boolean indicating that we are processing the optionsDataSource.
 boolean isRepeater()
          Gets whether a repeating contained options is on.
protected  void localRelease()
          Release any acquired resources.
 void setAccessKey(char accessKey)
          Sets the accessKey attribute value.
 void setMultiple(boolean multiple)
          Set whether multiple selections are allowed.
 void setNullable(boolean nullable)
          Set whether a null option is desired.
 void setNullableOptionText(String nullableOptionText)
          Set the text of the nullable option.
 void setRepeater(boolean repeater)
          Set whether repeating of contained options is on.
 void setRepeatingOrder(String order)
          This method will set the order of the options generated in the select.
 void setSize(int size)
          Sets how many options are displayed.
 void setTabindex(int tabindex)
          Sets the tabIndex of the rendered html tag.
 
Methods inherited from class HtmlOptionsDataSourceTag
setOptionsDataSource
 
Methods inherited from class HtmlDefaultableDataSourceTag
setDefaultValue
 
Methods inherited from class HtmlDataSourceTag
evaluateDataSource, nameHtmlControl, setDataSource
 
Methods inherited from class HtmlFocusBaseTag
isDisabled, setDisabled, setOnBlur, setOnChange, setOnFocus, setOnSelect
 
Methods inherited from class HtmlBaseTag
getJavaScriptAttribute, getOnClick, getTagId, renderDefaultNameAndId, renderNameAndId, setAttribute, setDir, setLang, setOnClick, setOnDblClick, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setStateAttribute, setStyle, setStyleClass, setTagId, setTitle
 
Methods inherited from class AbstractClassicTag
applyNamingChain, getErrorsReport, getIdForTagId, getNearestForm, getNextId, getScriptReporter, getUserLocale, hasErrors, qualifyAttribute, registerTagError, registerTagError, reportAndExit, reportErrors, rewriteName, setNonEmptyValueAttribute, setRequiredValueAttribute, write
 
Methods inherited from class BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Tag
getParent, setPageContext, setParent
 

Field Detail

NULL_VALUE

public static final String NULL_VALUE
Default value of the options value attribute.

See Also:
Constant Field Values
Constructor Detail

Select

public Select()
Method Detail

getTagName

public String getTagName()
Return the name of the Tag.

Specified by:
getTagName in interface INetuiTag
Specified by:
getTagName in class AbstractClassicTag
Returns:
the name of the tag.

getDataSource

public String getDataSource()
Description copied from interface: IDataAccessProvider
Get the expression that references the data item to which the IDataAccessProvider is bound.

Specified by:
getDataSource in interface IDataAccessProvider
Returns:
the expression referencing the data source or null if no dataSource is set

getState

protected AbstractHtmlState getState()
This method will return the state associated with the tag. This is used by this base class to access the individual state objects created by the tags.

Specified by:
getState in class HtmlBaseTag
Returns:
a subclass of the AbstractHtmlState class.

getNamingChain

protected List getNamingChain()
Return an ArrayList which represents a chain of INameInterceptor objects. This method by default returns null and should be overridden by objects that support naming.

Overrides:
getNamingChain in class HtmlDataSourceTag
Returns:
an ArrayList that will contain INameInterceptor objects.

evaluateDefaultValue

protected Object evaluateDefaultValue()
                               throws JspException
Evaluate the defaultValues

Throws:
JspException

setMultiple

public void setMultiple(boolean multiple)
Set whether multiple selections are allowed.

Parameters:
multiple - the multiple value ("true" or "false")

setRepeater

public void setRepeater(boolean repeater)
Set whether repeating of contained options is on.

Parameters:
repeater - the repeater value ("true" or "false")

isRepeater

public boolean isRepeater()
Gets whether a repeating contained options is on.

Returns:
the repeater value

setRepeatingOrder

public void setRepeatingOrder(String order)
                       throws JspException
This method will set the order of the options generated in the select. It must contain a comma separated string listing the order or the stages that the repeating types are processed. These values are "option", "dataSource", "default", and "null".

Parameters:
order - comma separated ordering of items when there is a repeating select.
Throws:
JspException

setNullable

public void setNullable(boolean nullable)
Set whether a null option is desired.

Parameters:
nullable - the nullable value

getOptionsDataSource

public Object getOptionsDataSource()
Gets the options datasource value (an expression).

Returns:
the options datasource

setNullableOptionText

public void setNullableOptionText(String nullableOptionText)
Set the text of the nullable option. If the nullable option is true, this is the text of that option. The default is "";


evaluateOptionsDataSource

protected Object evaluateOptionsDataSource()
                                    throws JspException
This method will return the object representing the optionsDataSource. This is overridden from the base class, because there are only two types which will be retunred from the method. The optionsDataSource will either be a instance of a Map or and instanceof a Iterator.

Returns:
the object instance object representing the objectsDataSource. This may be null.
Throws:
JspException - on an error

setSize

public void setSize(int size)
Sets how many options are displayed.

Parameters:
size - the size (a number)

isMatched

public boolean isMatched(String value)
Does the specified value match one of those we are looking for?

Parameters:
value - Value to be compared

getCurrentIndex

public int getCurrentIndex()
Get the current index in this iteration. This should be a zero based integer that increments after each iteration.

Specified by:
getCurrentIndex in interface IDataAccessProvider
Returns:
the current index of iteration or 0

getCurrentItem

public Object getCurrentItem()
Get the current data item in this IDataAccessProvider.

Specified by:
getCurrentItem in interface IDataAccessProvider
Returns:
the current data item or null

getCurrentMetadata

public Object getCurrentMetadata()
Get a metadata object for the current item. This interface is optional, and implementations of this interface are provided by the IDataAccessProvider interface. See these implementations for information about their support for current item metadata.

Specified by:
getCurrentMetadata in interface IDataAccessProvider
Returns:
the current metadata or null if no metadata can be found or metadata is not supported by a IDataAccessProvider implementation

getProviderParent

public IDataAccessProvider getProviderParent()
Get the parent IDataAccessProvider of a IDataAccessProvider. A IDataAccessProvider implementation may be able to nest IDataAccessProviders. In this case, it can be useful to be able to also nest access to data from parent providers. Implementations of this interface are left with having to discover and export parents. The return value from this call on an implementing Object can be null.

Specified by:
getProviderParent in interface IDataAccessProvider
Returns:
the parent IDataAccessProvider or null if this method is not supported or the parent can not be found.

getRepeatingStage

public Select.RepeatingStages getRepeatingStage()
Return the enum value of the currently repeating stage.

Returns:
The currently repeating stage.

isOptionStage

public boolean isOptionStage()
Boolean indicating that we are processing the optionsDataSource.

Returns:
true if we are processing the optionsDataSource.

isDefaultStage

public boolean isDefaultStage()
Boolean indicating that we are processing the defaultValue.

Returns:
true if we are processing the defaultValue.

isDataSourceStage

public boolean isDataSourceStage()
Boolean indicating that we are processing the dataSource.

Returns:
true if we are processing the dataSource.

isNullStage

public boolean isNullStage()
Boolean indicating that we are processing the defined null value.

Returns:
true if we are processing the defined null value.

doStartTag

public int doStartTag()
               throws JspException
Render the beginning of this select.

Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

doAfterBody

public int doAfterBody()
                throws JspException
Save any body content of this tag, which will generally be the option(s) representing the values displayed to the user.

Specified by:
doAfterBody in interface IterationTag
Overrides:
doAfterBody in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

doEndTag

public int doEndTag()
             throws JspException
Render the end of this select.

Specified by:
doEndTag in interface Tag
Overrides:
doEndTag in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

localRelease

protected void localRelease()
Release any acquired resources.

Overrides:
localRelease in class HtmlOptionsDataSourceTag

addFormatter

public void addFormatter(FormatTag.Formatter formatter)
Adds a FormatTag.Formatter to the Select's set of formatters

Specified by:
addFormatter in interface IFormattable
Parameters:
formatter - a FormatTag.Formatter added by a child FormatTag.

formatterHasError

public void formatterHasError()
Indicate that a formatter has reported an error so the formatter should output it's body text.

Specified by:
formatterHasError in interface IFormattable

addOptionToList

public void addOptionToList(String value)

formatText

public String formatText(Object text)
                  throws JspException
Apply the Select's set of formatters to the given text

Parameters:
text - the text to format.
Returns:
the formatted text
Throws:
JspException

setAccessKey

public void setAccessKey(char accessKey)
Sets the accessKey attribute value. This should key value of the keyboard navigation key. It is recommended not to use the following values because there are often used by browsers A, C, E, F, G, H, V, left arrow, and right arrow.

Parameters:
accessKey - the accessKey value.

setTabindex

public void setTabindex(int tabindex)
Sets the tabIndex of the rendered html tag.

Parameters:
tabindex - the tab index.