Class SelectElement


@TagName("select") public class SelectElement extends Element
The select element allows the selection of an option. The contained options can be directly accessed through the select element as a collection.
See Also:
  • Field Details

  • Constructor Details

    • SelectElement

      protected SelectElement()
  • Method Details

    • as

      public static SelectElement as(Element elem)
      Assert that the given Element is compatible with this class and automatically typecast it.
    • is

      public static boolean is(JavaScriptObject o)
      Determines whether the given JavaScriptObject can be cast to this class. A null object will cause this method to return false.
    • is

      public static boolean is(Node node)
      Determine whether the given Node can be cast to this class. A null node will cause this method to return false.
    • is

      public static boolean is(Element elem)
      Determine whether the given Element can be cast to this class. A null node will cause this method to return false.
    • add

      public final void add(OptionElement option, OptionElement before)
      Add a new element to the collection of OPTION elements for this SELECT. This method is the equivalent of the appendChild method of the Node interface if the before parameter is null. It is equivalent to the insertBefore method on the parent of before in all other cases. This method may have no effect if the new element is not an OPTION or an OPTGROUP.
      Parameters:
      option - The element to add
      before - The element to insert before, or null for the tail of the list
    • clear

      public final void clear()
      Removes all OPTION elements from this SELECT.
    • getDisabled

      @Deprecated public final String getDisabled()
      Deprecated.
      use isDisabled() instead.
      The control is unavailable in this context.
      See Also:
    • getForm

      public final FormElement getForm()
      Returns the FORM element containing this control. Returns null if this control is not within the context of a form.
    • getLength

      public final int getLength()
      The number of options in this SELECT.
    • getMultiple

      public final String getMultiple()
      If true, multiple OPTION elements may be selected in this SELECT.
      See Also:
    • getName

      public final String getName()
      Form control or object name when submitted with a form.
      See Also:
    • getOptions

      public final NodeList<OptionElement> getOptions()
      The collection of OPTION elements contained by this element.
    • getSelectedIndex

      public final int getSelectedIndex()
      The ordinal index of the selected option, starting from 0. The value -1 is returned if no element is selected. If multiple options are selected, the index of the first selected option is returned.
    • getSize

      public final int getSize()
      Number of visible rows.
      See Also:
    • getType

      public final String getType()
      The type of this form control. This is the string "select-multiple" when the multiple attribute is true and the string "select-one" when false.
    • getValue

      public final String getValue()
      The current form control value (i.e., the value of the currently selected option), if multiple options are selected this is the value of the first selected option.
    • isDisabled

      public final boolean isDisabled()
      The control is unavailable in this context.
      See Also:
    • isMultiple

      public final boolean isMultiple()
      If true, multiple OPTION elements may be selected in this SELECT.
      See Also:
    • remove

      public final void remove(int index)
      Remove an element from the collection of OPTION elements for this SELECT. Does nothing if no element has the given index.
      Parameters:
      index - The index of the item to remove, starting from 0.
    • setDisabled

      public final void setDisabled(boolean disabled)
      The control is unavailable in this context.
      See Also:
    • setDisabled

      public final void setDisabled(String disabled)
      The control is unavailable in this context.
      See Also:
    • setMultiple

      public final void setMultiple(boolean multiple)
      If true, multiple OPTION elements may be selected in this SELECT.
      See Also:
    • setName

      public final void setName(String name)
      Form control or object name when submitted with a form.
      See Also:
    • setSelectedIndex

      public final void setSelectedIndex(int index)
      The ordinal index of the selected option, starting from 0. The value -1 is returned if no element is selected. If multiple options are selected, the index of the first selected option is returned.
    • setSize

      public final void setSize(int size)
      Number of visible rows.
      See Also:
    • setType

      public final void setType(String type)
      The type of this form control. This is the string "select-multiple" when the multiple attribute is true and the string "select-one" when false.
    • setValue

      public final void setValue(String value)
      The current form control value (i.e., the value of the currently selected option), if multiple options are selected this is the value of the first selected option.