A single select component asks a user to choose one item from a list. It is similar to a simple dropbox implementation. The following listing shows an example:
link:../../../../../src/test/java/org/springframework/shell/docs/UiComponentSnippets.java[role=include]
The following screencast shows typical output for a single select component:
link:example$component-single-select-1.cast[role=include]
The context object is SingleItemSelectorContext
. The following table describes its context variables:
Key | Description |
---|---|
|
The returned value when the component exists. |
|
The visible items, where rows contains maps of name and selected items. |
|
The parent context variables (see SelectorComponentContext Template Variables). |
You can pre-select an item by defining it to get exposed. This is
useful if you know the default and lets the user merely press Enter
to make a choice.
The following listing sets a default:
link:../../../../../src/test/java/org/springframework/shell/docs/UiComponentSnippets.java[role=include]