@Generated(value={"Generator: com.vaadin.generator.ComponentGenerator#1.3-SNAPSHOT","WebComponent: Vaadin.SelectElement#2.0.2","Flow#1.3-SNAPSHOT"}) @Tag(value="vaadin-select") @HtmlImport(value="frontend://bower_components/vaadin-select/src/vaadin-select.html") public abstract class GeneratedVaadinSelect<R extends GeneratedVaadinSelect<R,T>,T> extends AbstractSinglePropertyField<R,T> implements HasStyle, Focusable<R>
Description copied from corresponding location in WebComponent:
<vaadin-select>
is a Web Component for selecting values from a list
of items. The content of the the select can be populated in two ways:
imperatively by using renderer callback function and declaratively by using
Polymer's Templates.
By default, the select uses the content provided by using the renderer callback function.
The renderer function provides root
, select
arguments.
Generate DOM content, append it to the root
element and control the
state of the host element by accessing select
.
<vaadin-select id="select"></vaadin-select>
const select = document.querySelector('#select');select.renderer =
function(root, select) const listBox =
document.createElement('vaadin-list-box'); // append 3 <vaadin-item> elements
['Jose', 'Manolo', 'Pedro'].forEach(function(name) { const item =
document.createElement('vaadin-item'); item.textContent = name;
listBox.appendChild(item); });
</p>
<p>
// update the content root.appendChild(listBox);
;}
Renderer is called on initialization of new select and on its opening. DOM
generated during the renderer call can be reused in the next renderer call
and will be provided with the root
argument. On first call it will be
empty.
Alternatively, the content can be provided with Polymer's Template. Select
finds the first child template and uses that in case renderer callback
function is not provided. You can also set a custom template using the
template
property.
<vaadin-select>
<template>
<vaadin-list-box>
<vaadin-item label="foo">Foo</vaadin-item>
<vaadin-item>Bar</vaadin-item>
<vaadin-item>Baz</vaadin-item>
</vaadin-list-box>
</template>
</vaadin-select>
Hint: By setting the label
property of inner vaadin-items you will be
able to change the visual representation of the selected value in the input
part.
The following shadow DOM parts are available for styling:
Part name | Description |
---|---|
toggle-button |
The toggle button |
The following state attributes are available for styling:
Attribute | Description | Part name |
---|---|---|
opened |
Set when the select is open | :host |
invalid |
Set when the element is invalid | :host |
focused |
Set when the element is focused | :host |
focus-ring |
Set when the element is keyboard focused | :host |
readonly |
Set when the select is read only | :host |
<vaadin-select>
element sets these custom CSS properties:
Property name | Description | Theme for element |
---|---|---|
--vaadin-select-text-field-width |
Width of the select text field | vaadin-select-overlay |
See ThemableMixin – how to apply styles for shadow parts
In addition to <vaadin-select>
itself, the following internal
components are themable:
<vaadin-select-text-field>
<vaadin-select-overlay>
Note: the theme
attribute value set on <vaadin-select>
is
propagated to the internal themable components listed above.
Modifier and Type | Class and Description |
---|---|
static class |
GeneratedVaadinSelect.InvalidChangeEvent<R extends GeneratedVaadinSelect<R,?>> |
static class |
GeneratedVaadinSelect.OpenedChangeEvent<R extends GeneratedVaadinSelect<R,?>> |
AbstractField.ComponentValueChangeEvent<C extends Component,V>
BlurNotifier.BlurEvent<C extends Component>
FocusNotifier.FocusEvent<C extends Component>
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
Constructor and Description |
---|
GeneratedVaadinSelect()
Default constructor.
|
GeneratedVaadinSelect(T initialValue,
T defaultValue,
boolean acceptNullValues)
Constructs a new GeneratedVaadinSelect component with the given
arguments.
|
GeneratedVaadinSelect(T initialValue,
T defaultValue,
Class<P> elementPropertyType,
SerializableBiFunction<R,P,T> presentationToModel,
SerializableBiFunction<R,T,P> modelToPresentation)
Constructs a new GeneratedVaadinSelect component with the given
arguments.
|
GeneratedVaadinSelect(T initialValue,
T defaultValue,
Class<P> elementPropertyType,
SerializableFunction<P,T> presentationToModel,
SerializableFunction<T,P> modelToPresentation)
Constructs a new GeneratedVaadinSelect component with the given
arguments.
|
Modifier and Type | Method and Description |
---|---|
protected Registration |
addInvalidChangeListener(ComponentEventListener<GeneratedVaadinSelect.InvalidChangeEvent<R>> listener)
Adds a listener for
invalid-changed events fired by the
webcomponent. |
protected Registration |
addOpenedChangeListener(ComponentEventListener<GeneratedVaadinSelect.OpenedChangeEvent<R>> listener)
Adds a listener for
opened-changed events fired by the
webcomponent. |
protected void |
addToPrefix(Component... components)
Adds the given components as children of this component at the slot
'prefix'.
|
protected String |
getErrorMessageString()
Description copied from corresponding location in WebComponent:
|
protected String |
getLabelString()
Description copied from corresponding location in WebComponent:
|
protected String |
getNameString()
Description copied from corresponding location in WebComponent:
|
protected String |
getPlaceholderString()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isAutofocusBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isDisabledBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isInvalidBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isOpenedBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isReadonlyBoolean()
Description copied from corresponding location in WebComponent:
|
protected boolean |
isRequiredBoolean()
Description copied from corresponding location in WebComponent:
|
protected void |
remove(Component... components)
Removes the given child components from this component.
|
protected void |
removeAll()
Removes all contents from this component, this includes child components,
text content as well as child elements that have been added directly to
this component using the
Element API. |
protected void |
render()
Description copied from corresponding location in WebComponent:
|
protected void |
setAutofocus(boolean autofocus)
Description copied from corresponding location in WebComponent:
|
protected void |
setDisabled(boolean disabled)
Description copied from corresponding location in WebComponent:
|
protected void |
setErrorMessage(String errorMessage)
Description copied from corresponding location in WebComponent:
|
protected void |
setInvalid(boolean invalid)
Description copied from corresponding location in WebComponent:
|
protected void |
setLabel(String label)
Description copied from corresponding location in WebComponent:
|
protected void |
setName(String name)
Description copied from corresponding location in WebComponent:
|
protected void |
setOpened(boolean opened)
Description copied from corresponding location in WebComponent:
|
protected void |
setPlaceholder(String placeholder)
Description copied from corresponding location in WebComponent:
|
protected void |
setReadonly(boolean readonly)
Description copied from corresponding location in WebComponent:
|
protected void |
setRequired(boolean required)
Description copied from corresponding location in WebComponent:
|
protected void |
validate()
Description copied from corresponding location in WebComponent:
|
hasValidValue, setPresentationValue, setSynchronizedEvent
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
addBlurListener
addFocusListener
isEnabled, setEnabled
getElement
isReadOnly, isRequiredIndicatorVisible, setReadOnly, setRequiredIndicatorVisible
clear, getOptionalValue
addAttachListener
addDetachListener
public GeneratedVaadinSelect(T initialValue, T defaultValue, Class<P> elementPropertyType, SerializableFunction<P,T> presentationToModel, SerializableFunction<T,P> modelToPresentation)
P
- the property typeinitialValue
- the initial value to set to the valuedefaultValue
- the default value to use if the value isn't definedelementPropertyType
- the type of the element propertypresentationToModel
- a function that converts a string value to a model valuemodelToPresentation
- a function that converts a model value to a string valuepublic GeneratedVaadinSelect(T initialValue, T defaultValue, boolean acceptNullValues)
initialValue
- the initial value to set to the valuedefaultValue
- the default value to use if the value isn't definedacceptNullValues
- whether null
is accepted as a model valuepublic GeneratedVaadinSelect(T initialValue, T defaultValue, Class<P> elementPropertyType, SerializableBiFunction<R,P,T> presentationToModel, SerializableBiFunction<R,T,P> modelToPresentation)
P
- the property typeinitialValue
- the initial value to set to the valuedefaultValue
- the default value to use if the value isn't definedelementPropertyType
- the type of the element propertypresentationToModel
- a function that accepts this component and a property value
and returns a model valuemodelToPresentation
- a function that accepts this component and a model value and
returns a property valuepublic GeneratedVaadinSelect()
protected boolean isAutofocusBoolean()
Description copied from corresponding location in WebComponent:
Specify that this control should have input focus when the page loads.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
autofocus
property from the webcomponentprotected void setAutofocus(boolean autofocus)
Description copied from corresponding location in WebComponent:
Specify that this control should have input focus when the page loads.
autofocus
- the boolean value to setprotected boolean isDisabledBoolean()
Description copied from corresponding location in WebComponent:
If true, the user cannot interact with this element.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
disabled
property from the webcomponentprotected void setDisabled(boolean disabled)
Description copied from corresponding location in WebComponent:
If true, the user cannot interact with this element.
disabled
- the boolean value to set@Synchronize(property="opened", value="opened-changed") protected boolean isOpenedBoolean()
Description copied from corresponding location in WebComponent:
Set when the select is open
This property is synchronized automatically from client side when a 'opened-changed' event happens.
opened
property from the webcomponentprotected void setOpened(boolean opened)
Description copied from corresponding location in WebComponent:
Set when the select is open
opened
- the boolean value to setprotected String getErrorMessageString()
Description copied from corresponding location in WebComponent:
The error message to display when the select value is invalid
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
errorMessage
property from the webcomponentprotected void setErrorMessage(String errorMessage)
Description copied from corresponding location in WebComponent:
The error message to display when the select value is invalid
errorMessage
- the String value to setprotected String getLabelString()
Description copied from corresponding location in WebComponent:
String used for the label element.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
label
property from the webcomponentprotected void setLabel(String label)
Description copied from corresponding location in WebComponent:
String used for the label element.
label
- the String value to setprotected boolean isRequiredBoolean()
Description copied from corresponding location in WebComponent:
The current required state of the select. True if required.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
required
property from the webcomponentprotected void setRequired(boolean required)
Description copied from corresponding location in WebComponent:
The current required state of the select. True if required.
required
- the boolean value to set@Synchronize(property="invalid", value="invalid-changed") protected boolean isInvalidBoolean()
Description copied from corresponding location in WebComponent:
Set to true if the value is invalid.
This property is synchronized automatically from client side when a 'invalid-changed' event happens.
invalid
property from the webcomponentprotected void setInvalid(boolean invalid)
Description copied from corresponding location in WebComponent:
Set to true if the value is invalid.
invalid
- the boolean value to setprotected String getNameString()
Description copied from corresponding location in WebComponent:
The name of this element.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
name
property from the webcomponentprotected void setName(String name)
Description copied from corresponding location in WebComponent:
The name of this element.
name
- the String value to setprotected String getPlaceholderString()
Description copied from corresponding location in WebComponent:
A hint to the user of what can be entered in the control. The placeholder will be displayed in the case that there is no item selected, or the selected item has an empty string label, or the selected item has no label and it's DOM content is empty.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
placeholder
property from the webcomponentprotected void setPlaceholder(String placeholder)
Description copied from corresponding location in WebComponent:
A hint to the user of what can be entered in the control. The placeholder will be displayed in the case that there is no item selected, or the selected item has an empty string label, or the selected item has no label and it's DOM content is empty.
placeholder
- the String value to setprotected boolean isReadonlyBoolean()
Description copied from corresponding location in WebComponent:
When present, it specifies that the element is read-only.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
readonly
property from the webcomponentprotected void setReadonly(boolean readonly)
Description copied from corresponding location in WebComponent:
When present, it specifies that the element is read-only.
readonly
- the boolean value to setprotected void render()
Description copied from corresponding location in WebComponent:
Manually invoke existing renderer.
@NotSupported protected void validate()
Description copied from corresponding location in WebComponent:
Returns true if value
is valid, and sets the invalid
flag
appropriately.
This function is not supported by Flow because it returns a
boolean
. Functions with return types different than void are
not supported at this moment.
protected Registration addOpenedChangeListener(ComponentEventListener<GeneratedVaadinSelect.OpenedChangeEvent<R>> listener)
opened-changed
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected Registration addInvalidChangeListener(ComponentEventListener<GeneratedVaadinSelect.InvalidChangeEvent<R>> listener)
invalid-changed
events fired by the
webcomponent.listener
- the listenerRegistration
for removing the event listenerprotected void addToPrefix(Component... components)
components
- The components to add.protected void remove(Component... components)
components
- The components to remove.IllegalArgumentException
- if any of the components is not a child of this component.protected void removeAll()
Element
API.Copyright © 2019. All rights reserved.