com.ibm.as400.util.html
Class SelectFormElement

java.lang.Object
  extended by com.ibm.as400.util.html.HTMLTagAttributes
      extended by com.ibm.as400.util.html.SelectFormElement
All Implemented Interfaces:
HTMLTagElement, Serializable

public class SelectFormElement
extends HTMLTagAttributes
implements Serializable

The SelectFormElement class represents a select input type in an HTML form. The trailing slash "/" on the SelectFormElement tag allows it to conform to the XHTML specification.

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:

See Also:
SelectOption, Serialized Form

Constructor Summary
Constructor and Description
SelectFormElement()
          Constructs a default SelectFormElement object.
SelectFormElement(String name)
          Constructs a SelectFormElement with the specified control name.
 
Method Summary
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(String text, String value)
          Adds an option with the specified viewable text and initial input value to the select form element.
 SelectOption addOption(String text, 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(VetoableChangeListener listener)
          Adds the VetoableChangeListener.
 String getDirection()
          Returns the direction of the text interpretation.
 String getFOTag()
          Returns a comment tag.
 String getLanguage()
          Returns the language of the input element.
 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.
 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(VetoableChangeListener listener)
          Removes the VetoableChangeListener from the internal list.
 void setDirection(String dir)
          Sets the direction of the text interpretation.
 void setLanguage(String lang)
          Sets the language of the input tag.
 void setMultiple(boolean multiple)
          Sets whether the user can make multiple selections.
 void setName(String name)
          Sets the control name of the select element.
 void setSize(int size)
          Sets the number of visible options.
 String toString()
          Returns the String representation of the select form element tag.
 
Methods inherited from class com.ibm.as400.util.html.HTMLTagAttributes
addPropertyChangeListener, getAttributes, getAttributeString, removePropertyChangeListener, setAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectFormElement

public SelectFormElement()
Constructs a default SelectFormElement object.


SelectFormElement

public SelectFormElement(String name)
Constructs a SelectFormElement with the specified control name.

Parameters:
name - The control name of the select element.
Method Detail

addElementListener

public void addElementListener(ElementListener listener)
Adds an addElementListener. The specified addElementListeners elementAdded method will be called each time a radioforminput is added to the group. The addElementListener object is added to a list of addElementListeners managed by this RadioFormInputGroup. It can be removed with removeElementListener.

Parameters:
listener - The ElementListener.
See Also:
removeElementListener(com.ibm.as400.util.html.ElementListener)

addOption

public void addOption(SelectOption option)
Adds an option to the select form element.

Parameters:
option - The select option.

addOption

public SelectOption addOption(String text,
                              String value)
Adds an option with the specified viewable text and initial input value to the select form element.

Parameters:
text - The viewable option text.
value - The option input value.
Returns:
A SelectOption object.

addOption

public SelectOption addOption(String text,
                              String value,
                              boolean selected)
Adds an option with the specified viewable text, initial input value, and initial selected value to the select form element. Only one option can be selected in the select form element at a time.

Parameters:
text - The viewable option text.
value - The option input value.
selected - true if the option defaults as being selected; false otherwise.
Returns:
A SelectOption object.

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener listener)
Adds the VetoableChangeListener. The specified VetoableChangeListener's vetoableChange method will be called each time the value of any constrained property is changed.

Parameters:
listener - The VetoableChangeListener.
See Also:
removeVetoableChangeListener(java.beans.VetoableChangeListener)

getDirection

public String getDirection()
Returns the direction of the text interpretation.

Returns:
The direction of the text.

getLanguage

public String getLanguage()
Returns the language of the input element.

Returns:
The language of the input element.

getName

public String getName()
Returns the control name of the select element.

Returns:
The control name.

getOptionCount

public int getOptionCount()
Returns the number of elements in the option layout.

Returns:
The number of elements.

getSize

public int getSize()
Returns the number of visible options.

Returns:
The number of options.

getFOTag

public String getFOTag()
Returns a comment tag. This method should not be called. There is no XSL-FO support for this class.

Specified by:
getFOTag in interface HTMLTagElement
Returns:
The comment tag.

getTag

public String getTag()
Returns the select form element tag.

Specified by:
getTag in interface HTMLTagElement
Returns:
The tag.

isMultiple

public boolean isMultiple()
Indicates if the user can make multiple selections.

Returns:
true if multiple selections are allowed; false otherwise.

removeOption

public void removeOption(SelectOption option)
Removes an option from the select form element.

Parameters:
option - The select option.

removeElementListener

public void removeElementListener(ElementListener listener)
Removes this ElementListener from the internal list. If the ElementListener is not on the list, nothing is done.

Parameters:
listener - The ElementListener.
See Also:
addElementListener(com.ibm.as400.util.html.ElementListener)

removeVetoableChangeListener

public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes the VetoableChangeListener from the internal list. If the VetoableChangeListener is not on the list, nothing is done.

Parameters:
listener - The VetoableChangeListener.
See Also:
addVetoableChangeListener(java.beans.VetoableChangeListener)

setDirection

public void setDirection(String dir)
                  throws PropertyVetoException
Sets the direction of the text interpretation.

Parameters:
dir - The direction. One of the following constants defined in HTMLConstants: LTR or RTL.
Throws:
PropertyVetoException - If a change is vetoed.
See Also:
HTMLConstants

setLanguage

public void setLanguage(String lang)
                 throws PropertyVetoException
Sets the language of the input tag.

Parameters:
lang - The language. Example language tags include: en and en-US.
Throws:
PropertyVetoException - If a change is vetoed.

setMultiple

public void setMultiple(boolean multiple)
                 throws PropertyVetoException
Sets whether the user can make multiple selections.

Parameters:
multiple - true if multiple selections are allowed; false otherwise.
Throws:
PropertyVetoException - If a change is vetoed.

setName

public void setName(String name)
             throws PropertyVetoException
Sets the control name of the select element.

Parameters:
name - The control name.
Throws:
PropertyVetoException - If a change is vetoed.

setSize

public void setSize(int size)
             throws PropertyVetoException
Sets the number of visible options.

Parameters:
size - The number of options.
Throws:
PropertyVetoException - If a change is vetoed.

toString

public String toString()
Returns the String representation of the select form element tag.

Overrides:
toString in class Object
Returns:
The tag.