com.ibm.as400.util.html

Class SelectOption

  • All Implemented Interfaces:
    HTMLTagElement, java.io.Serializable


    public class SelectOption
    extends HTMLTagAttributes
    implements java.io.Serializable
    The SelectOption class represents an option in an HTML option form element.
    The option form element is then used in an HTML select form element, which represents a group of selectable options. The trailing slash "/" on the SelectOption tag allows it to conform to the XHTML specification.

    This example creates a SelectOption object named item1 that is initially selected.

      SelectOption item1 = new SelectOption("Item1", "item1", true);
      System.out.println(item1.getTag());
      

    Here is the output of the SelectOption tag:

      <option value="item1" selected="selected">Item1</option>
      

    SelectOption objects generate the following events:

    • PropertyChangeEvent
    • VetoableChangeEvent
    See Also:
    SelectFormElement, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      SelectOption()
      Constructs a default SelectOption object.
      SelectOption(java.lang.String text, java.lang.String value)
      Constructs a SelectOption object with the specified viewable text and initial input value.
      SelectOption(java.lang.String text, java.lang.String value, boolean selected)
      Constructs a SelectOption object with the specified viewable text, initial input value, and initial selected value.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      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 getTag()
      Returns the select option tag.
      java.lang.String getTag(java.lang.String text)
      Returns the select option tag with the new viewable option text.
      java.lang.String getText()
      Returns the viewable option text.
      java.lang.String getValue()
      Returns the input value used when the field is submitted.
      boolean isSelected()
      Indicates if the option defaults to being selected.
      void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
      Removes the PropertyChangeListener from the internal list.
      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 setSelected(boolean selected)
      Sets whether the option defaults as being selected.
      void setText(java.lang.String text)
      Sets the option text with the specified viewable text.
      void setValue(java.lang.String value)
      Sets the input value used when the field is submitted.
      java.lang.String toString()
      Returns the String representation of the select option tag.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SelectOption

        public SelectOption()
        Constructs a default SelectOption object.
      • SelectOption

        public SelectOption(java.lang.String text,
                    java.lang.String value)
        Constructs a SelectOption object with the specified viewable text and initial input value. By default, the option is not selected.
        Parameters:
        text - The veiwable option text.
        value - The input value used when the field is submitted.
      • SelectOption

        public SelectOption(java.lang.String text,
                    java.lang.String value,
                    boolean selected)
        Constructs a SelectOption object with the specified viewable text, initial input value, and initial selected value.
        Parameters:
        text - The viewable option text.
        value - The input value used when the field is submitted.
        selected - Whether the option defaults as being selected.
    >
    • Method Detail

      • addVetoableChangeListener

        public void addVetoableChangeListener(java.beans.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 java.lang.String getDirection()
        Returns the direction of the text interpretation.
        Returns:
        The direction of the text.
      • getLanguage

        public java.lang.String getLanguage()
        Returns the language of the input element.
        Returns:
        The language of the input element.
      • getFOTag

        public java.lang.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 java.lang.String getTag()
        Returns the select option tag.
        Specified by:
        getTag in interface HTMLTagElement
        Returns:
        The tag.
      • getTag

        public java.lang.String getTag(java.lang.String text)
        Returns the select option tag with the new viewable option text. The original text of the select option object is not changed/updated.
        Parameters:
        text - The new option text.
        Returns:
        The tag.
      • getText

        public java.lang.String getText()
        Returns the viewable option text.
        Returns:
        The option text.
      • getValue

        public java.lang.String getValue()
        Returns the input value used when the field is submitted.
        Returns:
        The input value.
      • isSelected

        public boolean isSelected()
        Indicates if the option defaults to being selected.
        Returns:
        true if defaults as selected; false otherwise.
      • removeVetoableChangeListener

        public void removeVetoableChangeListener(java.beans.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(java.lang.String dir)
                          throws java.beans.PropertyVetoException
        Sets the direction of the text interpretation.
        Parameters:
        dir - The direction. One of the following constants defined in HTMLConstants: LTR or RTL.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
        See Also:
        HTMLConstants
      • setLanguage

        public void setLanguage(java.lang.String lang)
                         throws java.beans.PropertyVetoException
        Sets the language of the input tag.
        Parameters:
        lang - The language. Example language tags include: en and en-US.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • setSelected

        public void setSelected(boolean selected)
                         throws java.beans.PropertyVetoException
        Sets whether the option defaults as being selected.
        Parameters:
        selected - Whether the option defaults as selected.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • setText

        public void setText(java.lang.String text)
                     throws java.beans.PropertyVetoException
        Sets the option text with the specified viewable text.
        Parameters:
        text - The option text.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • setValue

        public void setValue(java.lang.String value)
                      throws java.beans.PropertyVetoException
        Sets the input value used when the field is submitted.
        Parameters:
        value - The input value.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • toString

        public java.lang.String toString()
        Returns the String representation of the select option tag.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The tag.