Interface HasHelper
- All Superinterfaces:
HasElement,Serializable
- All Known Subinterfaces:
InputField<E,V>
- All Known Implementing Classes:
AbstractNumberField,BigDecimalField,Checkbox,CheckboxGroup,ComboBox,ComboBoxBase,CustomField,DatePicker,DateTimePicker,EmailField,IntegerField,MultiSelectComboBox,NumberField,PasswordField,RadioButtonGroup,RangeSlider,Select,Slider,TextArea,TextField,TextFieldBase,TimePicker
Root element should be a web component that uses slot for example in the following way:
<field-with-helper>
<shadow-root>
...
<slot name="helper"></slot>
...
</shadow-root>
<span slot="helper">${helperText}</span>
</field-with-helper>
- Since:
- 2.4
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidbindHelperText(Signal<String> helperTextSignal) Binds a signal's value to the component's helper text so that the helper text is updated when the signal's value is updated.default ComponentGets the component in the helper slot of this field.default StringString used for the helper text.default voidsetHelperComponent(Component component) Adds the given component into helper slot of component, replacing any existing helper component.default voidsetHelperText(String helperText) String used for the helper text.Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Method Details
-
getHelperText
String used for the helper text.- Returns:
- the
helperTextproperty from the web component
-
setHelperText
String used for the helper text. It shows a text adjacent to the field that can be used, e.g., to inform to the users which values it expects. Example: a text "The password must contain numbers" for the PasswordField.
In case both
setHelperText(String)andsetHelperComponent(Component)are used, only the element defined bysetHelperComponent(Component)will be visible, regardless of the order on which they are defined.- Parameters:
helperText- the String value to set
-
bindHelperText
Binds a signal's value to the component's helper text so that the helper text is updated when the signal's value is updated.Passing
nullas thesignalremoves any existing binding for the given helper text. When unbinding, the current helper text is left unchanged.While a binding for the helper text is active, any attempt to set the text manually throws
BindingActiveException. The same happens when trying to bind a new Signal while one is already bound.Bindings are lifecycle-aware and only active while this component is in the attached state; they are deactivated while the component is in the detached state.
- Parameters:
helperTextSignal- the signal to bind, notnull- Throws:
BindingActiveException- thrown when there is already an existing binding- Since:
- 25.1
- See Also:
-
setHelperComponent
Adds the given component into helper slot of component, replacing any existing helper component. It adds the component adjacent to the field that can be used, e.g., to inform to the users which values it expects. Example: a component that shows the password strength for the PasswordField.- Parameters:
component- the component to set, can benullto remove existing helper component- See Also:
-
getHelperComponent
Gets the component in the helper slot of this field.- Returns:
- the helper component of this field, or
nullif no helper component has been set - See Also:
-