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, Formattable, HtmlConstants, IAttributeConsumer, IHtmlAttrs, IHtmlCore, IHtmlEvents, IHtmlI18n, INetuiTag

public class Select
extends HtmlOptionsDataSourceTag
implements IDataAccessProvider, Formattable

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>
        <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>

Field Summary
static String NULL_VALUE
          Default value of the options value attribute.
static String REPEATING_DATA
          Constant value of the repeatingType attribute for options handling the optionsDataSource, defaultValue and dataSource.
static String REPEATING_DATASOURCE
          Constant value of the repeatingType attribute for options handling the dataSource.
static String REPEATING_DEFAULT
          Constant value of the repeatingType attribute for options handling the defaultValue.
static String REPEATING_NULL
          Constant value of the repeatingType attribute for options handling the null option.
static String REPEATING_OPTION
          Constant value of the repeatingType attribute for options handling the optionsDataSource.
static int STAGE_DATASOURCE
          int value returned by getRepeatingStage when the dataSource is being processed.
static int STAGE_DEFAULT
          int value returned by getRepeatingStage when the defaultValue is being processed.
static int STAGE_NULL
          int value returned by getRepeatingStage when the null option is being processed.
static int STAGE_OPTION
          int value returned by getRepeatingStage when the optionsDataSource is being processed.
 
Fields inherited from class HtmlOptionsDataSourceTag
_optionsDataSource
 
Fields inherited from class HtmlDefaultableDataSourceTag
_defaultValue
 
Fields inherited from class HtmlDataSourceTag
_dataSource
 
Fields inherited from class HtmlBaseTag
JAVASCRIPT_STATUS
 
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
ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, 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, 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, RULES, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TD, TEXT, TEXTAREA, 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 NameInterceptor objects.
 Object getOptionsDataSource()
          Gets the options datasource value (an expression).
 IDataAccessProvider getProviderParent()
          Get the parent IDataAccessProvider of a IDataAccessProvider.
 int getRepeatingStage()
          This method will return the current stage being process when the select is acting as a repeater.
protected  AbstractHtmlState getState()
          This method will return the state associated with the tag.
 String getTagName()
          Return the name of the Tag.
 boolean isBindingOnClient()
          This method indicates that the expression of the repeater is bound into a client based context.
 boolean isMatched(String value)
          Does the specified value match one of those we are looking for?
 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 contains options is on.
 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
doNaming, evaluateDataSource, setDataSource
 
Methods inherited from class HtmlFocusBaseTag
isDisabled, setDisabled, setOnBlur, setOnChange, setOnFocus, setOnSelect
 
Methods inherited from class HtmlBaseTag
addTagIdMapping, getJavaScriptAttribute, getNearestForm, getNearestIdWriter, getOnClick, getTagId, isIdTransparency, qualifyUrlToContext, renderTagId, 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, getNextId, getScriptReporter, getUserLocale, hasErrors, qualifyAttribute, registerTagError, registerTagError, renderAttribute, 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

REPEATING_OPTION

public static final String REPEATING_OPTION
Constant value of the repeatingType attribute for options handling the optionsDataSource.

See Also:
Constant Field Values

REPEATING_DEFAULT

public static final String REPEATING_DEFAULT
Constant value of the repeatingType attribute for options handling the defaultValue.

See Also:
Constant Field Values

REPEATING_DATASOURCE

public static final String REPEATING_DATASOURCE
Constant value of the repeatingType attribute for options handling the dataSource.

See Also:
Constant Field Values

REPEATING_DATA

public static final String REPEATING_DATA
Constant value of the repeatingType attribute for options handling the optionsDataSource, defaultValue and dataSource.

See Also:
Constant Field Values

REPEATING_NULL

public static final String REPEATING_NULL
Constant value of the repeatingType attribute for options handling the null option.

See Also:
Constant Field Values

STAGE_OPTION

public static final int STAGE_OPTION
int value returned by getRepeatingStage when the optionsDataSource is being processed.

See Also:
Constant Field Values

STAGE_DATASOURCE

public static final int STAGE_DATASOURCE
int value returned by getRepeatingStage when the dataSource is being processed.

See Also:
Constant Field Values

STAGE_DEFAULT

public static final int STAGE_DEFAULT
int value returned by getRepeatingStage when the defaultValue is being processed.

See Also:
Constant Field Values

STAGE_NULL

public static final int STAGE_NULL
int value returned by getRepeatingStage when the null option is being processed.

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 NameInterceptor 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 NameInterceptor 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 contains 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

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.

isBindingOnClient

public boolean isBindingOnClient()
This method indicates that the expression of the repeater is bound into a client based context.

Returns:
true if the expression of this is bound on the client.

getRepeatingStage

public int getRepeatingStage()
This method will return the current stage being process when the select is acting as a repeater. Integer constants are defined for the return values, STAGE_OPTION, STAGE_DATASOURCE, STAGE_DEFAULT, STAGE_NULL

Returns:
an integer indicating the current repeating stage.

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 Formattable
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 Formattable

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.