Package com.groiss.gui.component
Class SelectList
java.lang.Object
com.groiss.gui.AbstractComponent
com.groiss.gui.component.SelectList
- All Implemented Interfaces:
Component
,Serializable
,Cloneable
- Direct Known Subclasses:
DropdownList
A HTML select list with size > 1.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class com.groiss.gui.AbstractComponent
ACTIVE, browserMode, DEFAULT, ID, IE, INVISIBLE, isSensitive, label, NS, ON_BLUR, ON_CHANGE, ON_CLICK, ON_DBLCLICK, ON_FOCUS, ON_KEY_DOWN, ON_KEY_PRESS, ON_KEY_UP, ON_LOAD, ON_MOUSE_DOWN, ON_MOUSE_MOVE, ON_MOUSE_OUT, ON_MOUSE_UP, ON_RESET, ON_SELECT, ON_SUBMIT, ON_UNLOAD, parent, parentElem, READONLY, root, viewMode
Fields inherited from interface com.groiss.gui.Component
LABELLEDBY
-
Constructor Summary
ConstructorDescriptionConstructs a new empty dropdown list component.SelectList
(String name, int size) Constructor with name.SelectList
(String name, Collection<?> list, int size) Constructor with name and content list.SelectList
(String name, Collection<?> list, int size, boolean showNull) Constructor with name and content list.SelectList
(String name, Collection<?> list, int size, boolean showNull, String selected) Constructor with name and content list.SelectList
(String name, Collection<?> list, int size, boolean showNull, String selected, String styleClass) Constructor with name and content list. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
adds a new option at the passed position within the dropdownlistvoid
addOption
(KeyValuePair<?, ?> p) Adds a new option at the end to the dropdownlistvoid
adds a new option at the end to the dropdownlistvoid
adds a new option at the end to the dropdownlistvoid
addOptions
(Collection<? extends KeyValuePair<?, ?>> options) Adds all options at the end of the dropdownlistvoid
clear()
removes all options from this selectlistvoid
deleteOption
(int index) Removes the specified option, if it can be identified, from the dropdownlist.void
deleteOption
(String value) Removes the specified option, if it can be identified, from the dropdownlist.void
deleteOption
(String value, String text) Deprecated.use method with one argumentGet the list of options.getOption
(int index) int
getOptionIndex
(String value, String text) returns the index of the specified option (identified by value-text-pairgetOptionText
(int index) Returns the displayed text of the specified option.Returns a vector with the displayed text of every option.getOptionValue
(int index) Returns the value of the specified option.Returns a vector with the value of every options.int
Returns the index of the selected option.int[]
returns a array of all selected optionsint
getSize()
returns the number of nested options in the dropdownlist - the sizeboolean
isSelected
(int index) Returns whether the specified option has the attribute SELECTED, or notvoid
Removes the attribute SELECTED from the selected option.void
removes the attribute SELECTED from the selected optionsvoid
setContent
(Object o) Sets the list of options.void
setContent
(Object o, boolean showNull) Sets the list of options.void
setContent
(Object o, KeyValuePair<?, ?> val) Sets the list of options.void
setDisplayedSize
(int size) sets the displayed list sizevoid
setMultiple
(boolean yesno) void
setSelectedOption
(int index) Adds the attribute SELECTED to the specified option.void
setSelectedOption
(String value) Adds the attribute SELECTED to the specified option.void
setSelectedOptions
(List<String> vals) Show the options text.Methods inherited from class com.groiss.gui.AbstractComponent
addClass, clone, create, getAttribute, getBrowserMode, getId, getLabel, getName, getParent, getParentElement, getRoot, getRootName, getStyle, getViewMode, init, init, init, removeAttribute, removeClass, setActionListener, setAttribute, setBrowserMode, setClass, setEncoding, setExpandEmptyElements, setId, setIndenting, setLabel, setName, setNewLines, setParent, setParentElement, setRootName, setStyle, setViewMode, show, show, toggleClass, toString
-
Field Details
-
OPTION
- See Also:
-
VALUE
- See Also:
-
SELECT
- See Also:
-
SIZE
- See Also:
-
MULTIPLE
- See Also:
-
SELECTED
- See Also:
-
OPTGROUP
- See Also:
-
-
Constructor Details
-
SelectList
public SelectList()Constructs a new empty dropdown list component. -
SelectList
Constructor with name.- Parameters:
name
- the name of the form element
-
SelectList
Constructor with name and content list.- Parameters:
name
- the name of the form elementlist
- the content listsize
- the number of visible lines
-
SelectList
Constructor with name and content list.- Parameters:
name
- the name of the form elementlist
- the content listsize
- the number of visible linesshowNull
- if true, add the option with value and display string empty to the begin of the list
-
SelectList
Constructor with name and content list.- Parameters:
name
- the name of the form elementlist
- the content listsize
- the number of visible linesshowNull
- if true, add the option with value and display string empty to the begin of the listselected
- the option where the value equals this argument is selected
-
SelectList
public SelectList(String name, Collection<?> list, int size, boolean showNull, String selected, String styleClass) Constructor with name and content list.- Parameters:
name
- the name of the form elementlist
- the content listsize
- the number of visible linesshowNull
- if true, add the option with value and display string empty to the begin of the listselected
- the option where the value equals this argument is selectedstyleClass
- the name of a CSS class
-
-
Method Details
-
setMultiple
public void setMultiple(boolean yesno) -
addOption
adds a new option at the end to the dropdownlist- Parameters:
value
- the value of the new optiontext
- the displayed text of the new option
-
addOption
-
addOption
-
addOption
adds a new option at the end to the dropdownlist- Parameters:
option
- an Element describing the option to add
-
addOption
adds a new option at the passed position within the dropdownlist- Parameters:
i
- the index where to add the optionoption
- an Element describing the option to add
-
addOption
Adds a new option at the end to the dropdownlist- Parameters:
p
- the new option
-
addOptions
Adds all options at the end of the dropdownlist- Parameters:
options
- the options
-
deleteOption
Deprecated.use method with one argumentRemoves the specified option, if it can be identified, from the dropdownlist.- Parameters:
value
- the value of the specified optiontext
- the displayed text of the new option
-
deleteOption
Removes the specified option, if it can be identified, from the dropdownlist.- Parameters:
value
- the value of the specified option
-
deleteOption
public void deleteOption(int index) Removes the specified option, if it can be identified, from the dropdownlist.- Parameters:
index
- the position of the specified option in the dropdownlist
-
getOptionText
Returns the displayed text of the specified option.- Parameters:
index
- the position of the specified option in the dropdownlist- Returns:
- the displayed text
-
getOption
-
getOptionValue
Returns the value of the specified option.- Parameters:
index
- the position of the specified option in the dropdownlist- Returns:
- the value
-
getSelectedOption
public int getSelectedOption()Returns the index of the selected option.- Returns:
- the index; if no option is selected "-1"
-
setSelectedOption
public void setSelectedOption(int index) Adds the attribute SELECTED to the specified option.- Parameters:
index
- the option which is selected
-
setSelectedOption
Adds the attribute SELECTED to the specified option.- Parameters:
value
- the option value which is selected
-
removeSelection
public void removeSelection()Removes the attribute SELECTED from the selected option. -
isSelected
public boolean isSelected(int index) Returns whether the specified option has the attribute SELECTED, or not- Parameters:
index
- the index of the specified option- Returns:
- true if the option is selected
-
getOptionValues
Returns a vector with the value of every options.- Returns:
- the Vector
-
getOptionTexts
Returns a vector with the displayed text of every option.- Returns:
- the Vector
-
getSize
public int getSize()returns the number of nested options in the dropdownlist - the size- Returns:
- the size
-
setContent
Sets the list of options.- Specified by:
setContent
in interfaceComponent
- Overrides:
setContent
in classAbstractComponent
- Parameters:
o
- must be a collection
-
setContent
Sets the list of options.- Parameters:
o
- a collection of objects for the optionsshowNull
- if true, add the option with value and display string empty to the begin of the list
-
setContent
Sets the list of options.- Parameters:
o
- a collection of objects for the optionsval
- a pair where the key equals one of the keys of the content parameter
-
getContent
Get the list of options.- Specified by:
getContent
in interfaceComponent
- Overrides:
getContent
in classAbstractComponent
- Returns:
- a list of pairs of value and text strings
-
showOptions
Show the options text.- Returns:
- the content object of the component
-
setSelectedOptions
-
getSelections
public int[] getSelections()returns a array of all selected options- Returns:
- the indeces of the selected options
-
removeSelections
public void removeSelections()removes the attribute SELECTED from the selected options -
setDisplayedSize
public void setDisplayedSize(int size) sets the displayed list size- Parameters:
size
- the size
-
getOptionIndex
returns the index of the specified option (identified by value-text-pair- Parameters:
value
- the value of the specified optiontext
- the displayed text of the specified option- Returns:
- the index of the specified option
-
clear
public void clear()removes all options from this selectlist
-