T - the data item typepublic class NativeSelect<T> extends AbstractSingleSelect<T> implements FieldEvents.FocusNotifier, FieldEvents.BlurNotifier, HasDataProvider<T>
<select> element. Lacks advanced features such as lazy
loading, filtering, and adding new items.ComboBox,
Serialized FormAbstractListing.AbstractListingExtension<T>Component.ErrorEvent, Component.Event, Component.Focusable, Component.ListenerClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerSizeable.UnitHasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>DESIGN_ATTR_PLAIN_TEXTSIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS| Constructor and Description |
|---|
NativeSelect()
Creates a new
NativeSelect with an empty caption and no items. |
NativeSelect(String caption)
Creates a new
NativeSelect with the given caption and no items. |
NativeSelect(String caption,
Collection<T> items)
Creates a new
NativeSelect with the given caption, containing the
data items in the given collection. |
NativeSelect(String caption,
DataProvider<T,?> dataProvider)
Creates a new
NativeSelect with the given caption, using the
given DataProvider as the source of data items. |
| Modifier and Type | Method and Description |
|---|---|
Registration |
addBlurListener(FieldEvents.BlurListener listener)
Adds a
BlurListener to the Component which gets fired
when a Field loses keyboard focus. |
Registration |
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FocusListener to the Component which gets fired
when a Field receives keyboard focus. |
DataProvider<T,?> |
getDataProvider()
Returns the source of data items used by this listing.
|
String |
getEmptySelectionCaption()
Returns the empty selection caption.
|
ItemCaptionGenerator<T> |
getItemCaptionGenerator()
Gets the item caption generator that is used to produce the strings shown
in the combo box for each item.
|
protected NativeSelectState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected NativeSelectState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
int |
getVisibleItemCount()
Gets the number of items that are visible.
|
boolean |
isEmptySelectionAllowed()
Returns whether the user is allowed to select nothing in the combo box.
|
void |
setDataProvider(DataProvider<T,?> dataProvider)
Sets the data provider for this listing.
|
void |
setEmptySelectionAllowed(boolean emptySelectionAllowed)
Sets whether the user is allowed to select nothing in the combo box.
|
void |
setEmptySelectionCaption(String caption)
Sets the empty selection caption.
|
void |
setItemCaptionGenerator(ItemCaptionGenerator<T> itemCaptionGenerator)
Sets the item caption generator that is used to produce the strings shown
in the combo box for each item.
|
void |
setVisibleItemCount(int visibleItemCount)
Sets the number of items that are visible.
|
addSelectionListener, addValueChangeListener, getCustomAttributes, getSelectedItem, getValue, isReadOnly, isRequiredIndicatorVisible, isSelected, keyToItem, readItem, readItems, setReadOnly, setRequiredIndicatorVisible, setSelectedItem, setSelectedItem, setValue, updateSelectedItemState, writeItemaddDataGenerator, deserializeDeclarativeRepresentation, doReadDesign, doWriteDesign, focus, getDataCommunicator, getItemIconGenerator, getTabIndex, internalGetDataProvider, internalSetDataProvider, internalSetDataProvider, readDesign, readItem, removeDataGenerator, serializeDeclarativeRepresentation, setItemIconGenerator, setTabIndex, writeDesign, writeItemsaddContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthFull, setWidthUndefinedaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstateclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitsetItemsaddListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesignaddAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdgetHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefinedclear, getDefaultValidator, getEmptyValue, getOptionalValue, isEmptypublic NativeSelect()
NativeSelect with an empty caption and no items.public NativeSelect(String caption)
NativeSelect with the given caption and no items.caption - the component caption to set, null for no captionpublic NativeSelect(String caption, Collection<T> items)
NativeSelect with the given caption, containing the
data items in the given collection.caption - the component caption to set, null for no captionitems - the data items to use, not nullpublic NativeSelect(String caption, DataProvider<T,?> dataProvider)
NativeSelect with the given caption, using the
given DataProvider as the source of data items.caption - the component caption to set, null for no captiondataProvider - the source of data items to use, not nullpublic Registration addFocusListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifierFocusListener to the Component which gets fired
when a Field receives keyboard focus.addFocusListener in interface FieldEvents.FocusNotifierlistener - the focus listener to add, not nullFieldEvents.FocusListener,
Registrationpublic Registration addBlurListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifierBlurListener to the Component which gets fired
when a Field loses keyboard focus.addBlurListener in interface FieldEvents.BlurNotifierlistener - the blur listener to add, not nullFieldEvents.BlurListener,
Registrationprotected NativeSelectState getState()
AbstractComponentgetState in class AbstractSingleSelect<T>protected NativeSelectState getState(boolean markAsDirty)
AbstractClientConnectorgetState in class AbstractSingleSelect<T>markAsDirty - true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()public DataProvider<T,?> getDataProvider()
HasItemsgetDataProvider in interface HasItems<T>public void setDataProvider(DataProvider<T,?> dataProvider)
HasDataProvidersetDataProvider in interface HasDataProvider<T>dataProvider - the data provider, not nullpublic void setItemCaptionGenerator(ItemCaptionGenerator<T> itemCaptionGenerator)
AbstractListingString.valueOf(Object) is used.setItemCaptionGenerator in class AbstractListing<T>itemCaptionGenerator - the item caption provider to use, not nullpublic ItemCaptionGenerator<T> getItemCaptionGenerator()
AbstractListinggetItemCaptionGenerator in class AbstractListing<T>public boolean isEmptySelectionAllowed()
public void setEmptySelectionAllowed(boolean emptySelectionAllowed)
emptySelectionAllowed - true to allow not selecting anything, false to require
selectionpublic String getEmptySelectionCaption()
The empty string "" is the default empty selection caption.
nullsetEmptySelectionAllowed(boolean),
isEmptySelectionAllowed(),
setEmptySelectionCaption(String),
AbstractSingleSelect.isSelected(Object)public void setEmptySelectionCaption(String caption)
The empty string "" is the default empty selection caption.
If empty selection is allowed via the
setEmptySelectionAllowed(boolean) method (it is by default) then
the empty item will be shown with the given caption.
caption - the caption to set, not nullAbstractSingleSelect.isSelected(Object)public void setVisibleItemCount(int visibleItemCount)
visibleItemCount - the visible item countIllegalArgumentException - if the value is smaller than onepublic int getVisibleItemCount()
Copyright © 2021 Vaadin Ltd. All rights reserved.