public class Select extends AbstractField
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
SELECT
The pattern used to create the html for a select form field.
|
private static long |
serialVersionUID
The class' serialization version id.
|
PARAM
ivHashCode, ivHashFlds, ivObjAttrs
Constructor and Description |
---|
Select(java.lang.String name)
Constructs a new instance of
Select using the supplied
parameters. |
Select(java.lang.String name,
int size)
Constructs a new instance of
Select using the supplied
parameters. |
Select(java.lang.String name,
int size,
boolean multiple)
Constructs a new instance of
Select using the supplied
parameters. |
Modifier and Type | Method and Description |
---|---|
void |
addOption(Option option)
Adds an option to the end of the select's set of options.
|
void |
deselectAllOptions()
Deselects all options within the select's set of options.
|
boolean |
equals(java.lang.Object obj)
Compares the given object to this object and determines if the two are
equal.
|
protected java.lang.String |
formatAttr(java.lang.String attr)
Returns a formatted html string for the requested attribute value.
|
boolean |
getMultiple()
Returns the select's multiselect state attribute.
|
java.lang.String |
getOnChange()
Returns the select's onchange event handler attribute.
|
int |
getSelectedIndex()
Returns the index of the selected option within the select's set of
options.
|
int[] |
getSelectedIndexes()
Returns the indexes for all selected options within the select's set of
options.
|
java.lang.String |
getSelectedValue()
Returns the value of the selected option within the select's set of
options.
|
java.lang.String[] |
getSelectedValues()
Returns the values for all selected options within the select's set of
options.
|
int |
getSize()
Returns the select's size attribute.
|
boolean |
hasOptions()
Answers if this select object has any options.
|
void |
insertBlankOption()
Inserts a blank (empty) option as the first option, if the first option
is not already a blank option.
|
void |
insertOptionAt(Option option,
int index)
Inserts an option at the specified index within the select's set of
options.
|
java.util.ArrayList<Option> |
options()
Returns the select's set of options.
|
java.lang.String |
optionsToHTML()
Returns a formatted html string for the select's set of options.
|
void |
removeAllOptions()
Removes all options within the select's set of options.
|
void |
removeOptionAt(int index)
Removes the option at the specified index within the select's set of
options.
|
void |
selectAllOptions()
Selects all options within the select's set of options.
|
void |
setMultiple(boolean multiple)
Sets the select's multiselect state attribute.
|
void |
setOnChange(java.lang.String onchange)
Sets the select's onchange event handler attribute.
|
void |
setSelectedIndex(int index)
Selects the option at the specified index within the select's set of
options.
|
void |
setSelectedValue(java.lang.String value)
Selects the option with the specified value within the select's set of
options.
|
void |
setSize(int size)
Sets the select's size attribute.
|
void |
sort()
Sorts the select's current set of options according to each option's text
attribute.
|
java.lang.String |
toHTML()
Returns a formatted html string for the select's current attribute
values and set of options.
|
getDisabled, getId, getName, getOnBlur, getOnClick, getOnDblClick, getOnFocus, getOnKeyDown, getOnKeyPress, getOnKeyUp, getOnMouseOut, getOnMouseOver, getStyleCls, getStyleStr, setDisabled, setId, setName, setOnBlur, setOnClick, setOnDblClick, setOnFocus, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseOut, setOnMouseOver, setStyleCls, setStyleStr
cloneMapAttributes, formatValue, formatValue, getHashFields, getMapArrayList, getMapAttributes, getMapBigDecimal, getMapBoolean, getMapDate, getMapDouble, getMapInteger, getMapLong, getMapMapped, getMapObject, getMapShort, getMapString, getMapString, getMapStringBuffer, getMapStringBuilder, getMapTime, getMapTimestamp, getMapVector, hashCode, setHashFields, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMap, setMapAttributes, setMapObject, setMapTime, setMapTimestamp, toStringArray
private static final long serialVersionUID
private static final java.lang.String SELECT
public Select(java.lang.String name)
Select
using the supplied
parameters. Defaults the select size to "1" and the multiselect state
to "single".name
- (String) The form field name for the select.public Select(java.lang.String name, int size)
Select
using the supplied
parameters. Defaults the select multiselect state to "single".name
- (String) The form field name for the select.size
- (int) The number of visible options for the select.public Select(java.lang.String name, int size, boolean multiple)
Select
using the supplied
parameters.name
- (String) The form field name for the select.size
- (int) The number of visible options for the select.multiple
- (boolean) true
to set the multiselect
state of the select to "multiple", otherwise false
.public boolean equals(java.lang.Object obj)
equals
in class MappedAttributesObject
obj
- (Object) The object to compare with this object.true
if the specified object is equal to
this object, otherwise false
.protected java.lang.String formatAttr(java.lang.String attr)
formatAttr
in AbstractField
.formatAttr
in class AbstractField
AbstractField.formatAttr(java.lang.String)
public java.lang.String toHTML()
toHTML
in AbstractField
.toHTML
in class AbstractField
AbstractField.toHTML()
public boolean getMultiple()
public void setMultiple(boolean multiple)
multiple
- (boolean) The select's multiselect state.public java.lang.String getOnChange()
public void setOnChange(java.lang.String onchange)
onchange
- (String) The select's onchange event handler.public int getSize()
public void setSize(int size)
size
- (int) The select's size.public void addOption(Option option)
option
- (Option) The option to add.public void deselectAllOptions()
public int getSelectedIndex()
public int[] getSelectedIndexes()
null
if
no options are selected.public java.lang.String getSelectedValue()
null
if there are no selected options.public java.lang.String[] getSelectedValues()
null
if
no options are selected.public boolean hasOptions()
true
if the select has options,
otherwise false
.public void insertBlankOption()
public void insertOptionAt(Option option, int index)
option
- (Option) The option to insert.index
- (int) The index where the option is to be inserted.public java.util.ArrayList<Option> options()
public java.lang.String optionsToHTML()
public void removeOptionAt(int index)
index
- (int) The index for the option to be removed.public void removeAllOptions()
public void selectAllOptions()
public void setSelectedIndex(int index)
index
- (int) The index for the option to be selected.public void setSelectedValue(java.lang.String value)
value
- (String) The value for the option to be selected.public void sort()