Common Handlers
AttachEvent
com.vaadin.flow.component.AttachEvent
is sent after the component is attached to the UI.
ClientValidatedEvent
com.vaadin.flow.component.shared.HasClientValidation.ClientValidatedEvent
fired by the web component whenever it is validated on the client-side. This event corresponds to the validated
DOM event.
ComponentValueChangeEvent
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent
is sent when the component’s input value changes.
For typed components use TypedValueChangeEvent to ensure that the input value is correctly typed and avoid the need for additional type conversions or checks. |
CompositionEndEvent
com.vaadin.flow.component.CompositionEndEvent
is sent when a composition is ended. Corresponds to the compositionend
DOM event.
CompositionStartEvent
com.vaadin.flow.component.CompositionStartEvent
is sent when a composition is started. Corresponds to the compositionstart
DOM event.
CompositionUpdateEvent
com.vaadin.flow.component.CompositionUpdateEvent
is sent when a composition is updated. Corresponds to the compositionupdate
DOM event.
DetachEvent
com.vaadin.flow.component.DetachEvent
is sent before the component is detached from the UI.
InputEvent
com.vaadin.flow.component.InputEvent
fired when the component has received any type of input (for example, click, key press). Corresponds to the input
DOM event.
KeyDownEvent
com.vaadin.flow.component.KeyDownEvent
is sent when a key is pressed. Corresponds to the keydown
DOM event.
KeyPressEvent
com.vaadin.flow.component.KeyPressEvent
is sent when a key is pressed. Corresponds to the keypress
DOM event.
KeyUpEvent
com.vaadin.flow.component.KeyUpEvent
is sent when a key is released. Corresponds to the keyup
DOM event.
statusChangeHandler
io.jmix.flowui.component.SupportsStatusChangeHandler
is used to handle component status changes, for example, validation messages set by the HasValidation.setErrorMessage(String)
method.
For example, instead of displaying validation messages below the component, you can use a separate component, such as Label
:
<textField id="negativeField" datatype="int">
<validators>
<negative/>
</validators>
</textField>
<div id="infoLabel" visible="false"/>
The handler should be defined as follows:
@ViewComponent
private Div infoLabel;
@Install(to = "negativeField", subject = "statusChangeHandler")
private void negativeFieldStatusChangeHandler(
SupportsStatusChangeHandler.StatusContext<TypedTextField<String>>
statusContext) {
infoLabel.setVisible(true); (1)
infoLabel.setText(statusContext.getDescription()); (2)
}
1 | Makes infoLabel visible. |
2 | Gets the error message from the StatusContext object and sets it to the infoLabel text. |
TypedValueChangeEvent
io.jmix.flowui.component.SupportsTypedValue.TypedValueChangeEvent
is sent when the user finished the manipulations with the component. For example, after the Enter
press or when the component loses focus.
An event has the following methods:
-
getOldValue()
returns the typed component’s value before the change. -
getValue()
returns the current typed component’s value.
@Autowired
protected Notifications notifications;
@Subscribe("nameField")
protected void onNameFieldTypedValueChange(
SupportsTypedValue.TypedValueChangeEvent<TypedTextField<String>, String> event) {
notifications
.show("Before: " + event.getOldValue() +
". After: " + event.getValue());
}