com.ibm.as400.util.html

Class SelectFormElement

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


    public class SelectFormElement
    extends HTMLTagAttributes
    implements java.io.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:

    • ElementEvent - The events fired are:
      • elementAdded
      • elementRemoved
    • PropertyChangeEvent
    • VetoableChangeEvent
    See Also:
    SelectOption, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      SelectFormElement()
      Constructs a default SelectFormElement object.
      SelectFormElement(java.lang.String name)
      Constructs a SelectFormElement with the specified control name.
    • Method Summary

      Methods 
      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.
      • 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(java.lang.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(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.
        Parameters:
        text - The viewable option text.
        value - The option input value.
        Returns:
        A SelectOption object.
      • addOption

        public 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. 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(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.
      • getName

        public java.lang.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 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 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.
      • 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.
      • setMultiple

        public void setMultiple(boolean multiple)
                         throws java.beans.PropertyVetoException
        Sets whether the user can make multiple selections.
        Parameters:
        multiple - true if multiple selections are allowed; false otherwise.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • setName

        public void setName(java.lang.String name)
                     throws java.beans.PropertyVetoException
        Sets the control name of the select element.
        Parameters:
        name - The control name.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • setSize

        public void setSize(int size)
                     throws java.beans.PropertyVetoException
        Sets the number of visible options.
        Parameters:
        size - The number of options.
        Throws:
        java.beans.PropertyVetoException - If a change is vetoed.
      • toString

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