Class DataList<T extends DataList<T>>


public class DataList<T extends DataList<T>> extends StyledElement<T>
Represents an HTML <datalist> element for pre-defined input options.

The DataList element contains a set of <option> elements that represent pre-defined options for an <input> element. It provides an autocomplete feature, allowing users to see a dropdown of pre-defined options as they type.

Features:

  • Autocomplete functionality for input fields
  • Contains option elements for suggestions
  • Referenced by input element's list attribute
  • Improves user experience with suggestions

Usage:


 DataList browsers = new DataList();
 browsers.setId("browsers");
 browsers.addOption("Chrome");
 browsers.addOption("Firefox");
 browsers.addOption("Safari");
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • DataList

      public DataList()
      Constructs an empty <datalist> element.
  • Method Details

    • addOption

      public void addOption(String value)
      Adds an option with the specified value to the datalist.
      Parameters:
      value - the option value
    • addOption

      public void addOption(Option option)
      Adds an option element to the datalist.
      Parameters:
      option - the Option element to add
    • setList

      public final T setList(String dataListId)
      Sets the list attribute (typically used on the input element, not datalist).
      Parameters:
      dataListId - the datalist ID to reference
      Returns:
      this element for method chaining
    • removeAllElements

      public void removeAllElements()
      Removes all option elements from this datalist.
      Overrides:
      removeAllElements in class Element<T extends DataList<T>>