DataSelect is intended for huge option sets where eagerly rendering every option would be expensive. It delegates option presentation to a virtualized DataList.
The selected option is tracked as a VirtualItem, and its rendered field value can be customized through DataSelectItemValueMapper and DataOptionMeta.
V
the value type represented by each option
AbstractDataSelect keeps selection controls responsive for huge option sets by delegating option rendering to the moving-window infrastructure in this package.
It owns the text input, placeholder, type-to-select behavior, option search, selection helpers, and missing-option hooks that concrete controls such as DataSelect build on.
T
the value type represented by the select
I
the rendered data list item type used for options
C
the concrete select subtype
DataList renders only the visible slice of its backing collection while the full record set remains searchable, selectable, and incrementally mutable.
It works with rendered rows such as DataListItem and CheckableDataListItem, wraps each record as a VirtualItem, and delegates window management to ScrollingWindowList and VirtualScrollPanel.
V
the record type represented by the list
I
the rendered row type used for visible items
DataListItem builds on AbstractDataListItem by rendering a simple text span for the record and exposing hooks for custom clickable behavior.
V
the value type represented by the row
Each VirtualItem lazily owns the rendered window item for the current viewport while keeping selection state, metadata, and key resolution attached to the underlying record.
This lets DataList and DataSelect track selection even when a row is currently outside the rendered window.
T
the wrapped record type
I
the rendered window item type
Implementations let a closed select render richer content than plain text by converting the selected row into a DOM node.
T
the value type represented by the selected item
DataOptionMeta is used by DataSelect to keep the selected-value node attached to the active option and to remove that node cleanly when selection changes.
public static DataSelect<V> create(VirtualScrollItemMapper<V, DataListItem<V>> mapper, KeyProvider<V> keyProvider)
mapper
maps option records into rendered data list rows
keyProvider
resolves stable keys for the option records
V
the option value type
public static DataSelect<V> create(String label, VirtualScrollItemMapper<V, DataListItem<V>> mapper, KeyProvider<V> keyProvider)
label
the form label to apply to the select
mapper
maps option records into rendered data list rows
keyProvider
resolves stable keys for the option records
V
the option value type
public DataSelect<V> withOption(VirtualItem<V, DataListItem<V>> option, boolean silent)
option
the virtual option to mark as selected
silent
true to avoid notifying change listeners
public V getValue()
the selected value, or null when nothing is selected
public VirtualItem<V, DataListItem<V>> getSelectedOption()
the selected option wrapper, or null if no option is selected
public DataSelect<V> setAutoFocus(boolean autoFocus)
autoFocus
true to keep focus on the select after updates
public boolean isAutoFocus()
true when autofocus is enabled
public void AbstractDataSelect(VirtualScrollItemMapper<T, I> mapper, KeyProvider<T> keyProvider)
mapper
maps each option record into its rendered list row
keyProvider
resolves stable keys for the option records
public C setPlaceholder(String placeholder)
placeholder
the placeholder text to display
public C setTypeToSelect(boolean typeToSelect)
typeToSelect
true to allow typing directly into the select for quick matching
public C withValue(T value, boolean silent)
value
the value to select
silent
true to avoid notifying change listeners
public DataList<T, I> getOptionsMenu()
the backing DataList instance
public C selectByValue(T value, boolean silent)
value
the option value to select
silent
true to avoid notifying change listeners
public C setSearchable(DataFilter<T> dataFilter)
dataFilter
the search predicate applied to each option record
public C withOptionsMenu(ChildHandler<C, DataList<T, I>> handler)
handler
receives the select instance and its options menu
public C setOptions(Collection<T> records)
records
the new option records
public static DataList<V, I> create(VirtualScrollItemMapper<V, I> mapper, KeyProvider<V> keyProvider)
mapper
maps each record into its rendered list item
keyProvider
resolves stable keys for record lookup and selection
V
the record type
I
the rendered row type
a new DataList instance
public DataList<V, I> setItems(List<V> items)
items
the records to expose through the list
this DataList instance
public DataList<V, I> setSearchable(DataFilter<V> dataFilter)
dataFilter
the search predicate to apply for each record, or null to disable searching
this DataList instance
public List<I> getWindowItems()
the list items currently materialized in the viewport
public Optional<I> findOptionStarsWith(String token)
token
the prefix to match against visible rows
the first matching rendered row, if one is currently in the window
public DataList<V, I> selectAll(boolean silent)
silent
true to suppress selection listener callbacks while selecting
this DataList instance
public DataList<V, I> deselectAll(boolean silent)
silent
true to suppress deselection listener callbacks while clearing
this DataList instance
public VirtualScrollListVirtualScroll<V, I> getVirtualScrollPanel()
the virtual scroll panel used by this list
public void DataListItem(String text, V value)
text
the text displayed inside the row body
value
the record represented by the row
public static DataListItem<V> create(String text, V value)
text
the text displayed inside the row body
value
the record represented by the row
V
the value type represented by the row
a new DataListItem instance
public DataListItem<V> withClickableElement(ChildHandler<DataListItem<V>, AnchorElement> handler)
handler
receives the row and its clickable anchor element
the current DataListItem instance
public SpanElement getTextElement()
the text element for this row, or null when no text was supplied
public void VirtualItem(T record, VirtualScrollItemMapper<T, I> mapper, KeyProvider<T> keyProvider)
record
the underlying record
mapper
creates the rendered window item when needed
keyProvider
resolves stable keys for the wrapped record
public VirtualItem<T, I> select(boolean silent)
silent
true to suppress selection listeners
public VirtualItem<T, I> deselect(boolean silent)
silent
true to suppress deselection listeners
public I windowItem()
the rendered window item for the current record
public T getRecord()
the record associated with this virtual item
public VirtualItem<T, I> setSelectable(boolean selectable)
selectable
true when the record should be selectable
public String getKey()
the key that identifies this virtual item
public Node toElement(DataListItem<T> item)
item
the selected rendered option row
public static DataOptionMeta of(Node component)
component
the rendered node to attach to the option
public static Optional<DataOptionMeta> get(HasMeta<?> component)
component
the component to inspect for option metadata
public static void clear(HasMeta<?> component)
component
the component whose selected-value metadata should be removed
public Node getComponent()
the selected-value node
public String getKey()
the metadata key for option content