org.apache.struts.taglib.html

Class OptionsCollectionTag

public class OptionsCollectionTag extends TagSupport

Tag for creating multiple <select> options from a collection. The collection may be part of the enclosing form, or may be independent of the form. Each element of the collection must expose a 'label' and a 'value', the property names of which are configurable by attributes of this tag.

The collection may be an array of objects, a Collection, an Enumeration, an Iterator, or a Map.

NOTE - This tag requires a Java2 (JDK 1.2 or later) platform.

Since: Struts 1.1

Version: $Rev: 56513 $ $Date: 2004-11-03 19:20:47 +0000 (Wed, 03 Nov 2004) $

Field Summary
protected booleanfilter
Should the label values be filtered for HTML sensitive characters?
protected Stringlabel
The name of the bean property containing the label.
protected static MessageResourcesmessages
The message resources for this package.
protected Stringname
The name of the bean containing the values collection.
protected Stringproperty
The name of the property to use to build the values collection.
Stringstyle
The style associated with this tag.
StringstyleClass
The named style class associated with this tag.
protected Stringvalue
The name of the bean property containing the value.
Method Summary
protected voidaddOption(StringBuffer sb, String label, String value, boolean matched)
Add an option element to the specified StringBuffer based on the specified parameters.
intdoStartTag()
Process the start of this tag.
booleangetFilter()
protected IteratorgetIterator(Object collection)
Return an iterator for the options collection.
StringgetLabel()
StringgetName()
StringgetProperty()
StringgetStyle()
StringgetStyleClass()
StringgetValue()
voidrelease()
Release any acquired resources.
voidsetFilter(boolean filter)
voidsetLabel(String label)
voidsetName(String name)
voidsetProperty(String property)
voidsetStyle(String style)
voidsetStyleClass(String styleClass)
voidsetValue(String value)

Field Detail

filter

protected boolean filter
Should the label values be filtered for HTML sensitive characters?

label

protected String label
The name of the bean property containing the label.

messages

protected static MessageResources messages
The message resources for this package.

name

protected String name
The name of the bean containing the values collection.

property

protected String property
The name of the property to use to build the values collection.

style

private String style
The style associated with this tag.

styleClass

private String styleClass
The named style class associated with this tag.

value

protected String value
The name of the bean property containing the value.

Method Detail

addOption

protected void addOption(StringBuffer sb, String label, String value, boolean matched)
Add an option element to the specified StringBuffer based on the specified parameters.

Note that this tag specifically does not support the styleId tag attribute, which causes the HTML id attribute to be emitted. This is because the HTML specification states that all "id" attributes in a document have to be unique. This tag will likely generate more than one option element element, but it cannot use the same id value. It's conceivable some sort of mechanism to supply an array of id values could be devised, but that doesn't seem to be worth the trouble.

Parameters: sb StringBuffer accumulating our results value Value to be returned to the server for this option label Value to be shown to the user for this option matched Should this value be marked as selected?

doStartTag

public int doStartTag()
Process the start of this tag.

Throws: JspException if a JSP exception has occurred

getFilter

public boolean getFilter()

getIterator

protected Iterator getIterator(Object collection)
Return an iterator for the options collection.

Parameters: collection Collection to be iterated over

Throws: JspException if an error occurs

getLabel

public String getLabel()

getName

public String getName()

getProperty

public String getProperty()

getStyle

public String getStyle()

getStyleClass

public String getStyleClass()

getValue

public String getValue()

release

public void release()
Release any acquired resources.

setFilter

public void setFilter(boolean filter)

setLabel

public void setLabel(String label)

setName

public void setName(String name)

setProperty

public void setProperty(String property)

setStyle

public void setStyle(String style)

setStyleClass

public void setStyleClass(String styleClass)

setValue

public void setValue(String value)
Copyright © 2000-2008 - The Apache Software Foundation