public class SelectFormElement extends HTMLTagAttributes implements java.io.Serializable
This example creates a SelectFormElement object with three options and prints out the HTML tag. The first two options added specify the option text, name, and select attributes. The third option added is defined by a SelectOption object.
SelectFormElement list = new SelectFormElement("list1"); SelectOption option1 = list.addOption("Option1", "opt1"); SelectOption option2 = list.addOption("Option2", "opt2", false); SelectOption option3 = new SelectOption("Option3", "opt3", true); list.addOption(option3); System.out.println(list.getTag());
Here is the output of the SelectFormElement tag:
<select name="list1"> <option value="opt1">Option1</option> <option value="opt2">Option2</option> <option value="opt3" selected="selected">Option3</option> </select>
SelectFormElement objects generate the following events:
SelectOption
,
Serialized FormConstructor and Description |
---|
SelectFormElement()
Constructs a default SelectFormElement object.
|
SelectFormElement(java.lang.String name)
Constructs a SelectFormElement with the specified control name.
|
Modifier and Type | Method and Description |
---|---|
void |
addElementListener(ElementListener listener)
Adds an addElementListener.
|
void |
addOption(SelectOption option)
Adds an option to the select form element.
|
SelectOption |
addOption(java.lang.String text,
java.lang.String value)
Adds an option with the specified viewable text and initial input
value to the select form element.
|
SelectOption |
addOption(java.lang.String text,
java.lang.String value,
boolean selected)
Adds an option with the specified viewable text, initial input value,
and initial selected value to the select form element.
|
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds the VetoableChangeListener.
|
java.lang.String |
getDirection()
Returns the direction of the text interpretation.
|
java.lang.String |
getFOTag()
Returns a comment tag.
|
java.lang.String |
getLanguage()
Returns the language of the input element.
|
java.lang.String |
getName()
Returns the control name of the select element.
|
int |
getOptionCount()
Returns the number of elements in the option layout.
|
int |
getSize()
Returns the number of visible options.
|
java.lang.String |
getTag()
Returns the select form element tag.
|
boolean |
isMultiple()
Indicates if the user can make multiple selections.
|
void |
removeElementListener(ElementListener listener)
Removes this ElementListener from the internal list.
|
void |
removeOption(SelectOption option)
Removes an option from the select form element.
|
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes the VetoableChangeListener from the internal list.
|
void |
setDirection(java.lang.String dir)
Sets the direction of the text interpretation.
|
void |
setLanguage(java.lang.String lang)
Sets the language of the input tag.
|
void |
setMultiple(boolean multiple)
Sets whether the user can make multiple selections.
|
void |
setName(java.lang.String name)
Sets the control name of the select element.
|
void |
setSize(int size)
Sets the number of visible options.
|
java.lang.String |
toString()
Returns the String representation of the select form element tag.
|
addPropertyChangeListener, getAttributes, getAttributeString, removePropertyChangeListener, setAttributes
public SelectFormElement()
public SelectFormElement(java.lang.String name)
name
- The control name of the select element.public void addElementListener(ElementListener listener)
listener
- The ElementListener.removeElementListener(com.ibm.as400.util.html.ElementListener)
public void addOption(SelectOption option)
option
- The select option.public SelectOption addOption(java.lang.String text, java.lang.String value)
text
- The viewable option text.value
- The option input value.public SelectOption addOption(java.lang.String text, java.lang.String value, boolean selected)
text
- The viewable option text.value
- The option input value.selected
- true if the option defaults as being selected; false otherwise.public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The VetoableChangeListener.removeVetoableChangeListener(java.beans.VetoableChangeListener)
public java.lang.String getDirection()
public java.lang.String getLanguage()
public java.lang.String getName()
public int getOptionCount()
public int getSize()
public java.lang.String getFOTag()
getFOTag
in interface HTMLTagElement
public java.lang.String getTag()
getTag
in interface HTMLTagElement
public boolean isMultiple()
public void removeOption(SelectOption option)
option
- The select option.public void removeElementListener(ElementListener listener)
listener
- The ElementListener.addElementListener(com.ibm.as400.util.html.ElementListener)
public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The VetoableChangeListener.addVetoableChangeListener(java.beans.VetoableChangeListener)
public void setDirection(java.lang.String dir) throws java.beans.PropertyVetoException
dir
- The direction. One of the following constants
defined in HTMLConstants: LTR or RTL.java.beans.PropertyVetoException
- If a change is vetoed.HTMLConstants
public void setLanguage(java.lang.String lang) throws java.beans.PropertyVetoException
lang
- The language. Example language tags include:
en and en-US.java.beans.PropertyVetoException
- If a change is vetoed.public void setMultiple(boolean multiple) throws java.beans.PropertyVetoException
multiple
- true if multiple selections are allowed; false otherwise.java.beans.PropertyVetoException
- If a change is vetoed.public void setName(java.lang.String name) throws java.beans.PropertyVetoException
name
- The control name.java.beans.PropertyVetoException
- If a change is vetoed.public void setSize(int size) throws java.beans.PropertyVetoException
size
- The number of options.java.beans.PropertyVetoException
- If a change is vetoed.public java.lang.String toString()
toString
in class java.lang.Object