From fd00c6e15e9c6d8119d403575a3795a222cef2f9 Mon Sep 17 00:00:00 2001 From: Sergey Vinogradov Date: Wed, 25 Sep 2024 17:38:29 +0400 Subject: [PATCH] add error messages to ComboBox examples --- frontend/demo/component/combobox/combo-box-validation.ts | 1 + .../demo/component/combobox/react/combo-box-validation.tsx | 1 + .../com/vaadin/demo/component/combobox/ComboBoxValidation.java | 3 +++ 3 files changed, 5 insertions(+) diff --git a/frontend/demo/component/combobox/combo-box-validation.ts b/frontend/demo/component/combobox/combo-box-validation.ts index f92bc48678..95d534527d 100644 --- a/frontend/demo/component/combobox/combo-box-validation.ts +++ b/frontend/demo/component/combobox/combo-box-validation.ts @@ -21,6 +21,7 @@ export class Example extends LitElement { allowed-char-pattern="[A-Z]" label="Country code" helper-text="2-letter uppercase ISO country code" + error-message="Field is required" allow-custom-value .items="${['DE', 'FI', 'US']}" > diff --git a/frontend/demo/component/combobox/react/combo-box-validation.tsx b/frontend/demo/component/combobox/react/combo-box-validation.tsx index b4fd7de2bd..f3d77a4330 100644 --- a/frontend/demo/component/combobox/react/combo-box-validation.tsx +++ b/frontend/demo/component/combobox/react/combo-box-validation.tsx @@ -10,6 +10,7 @@ function Example() { allowedCharPattern="[A-Z]" label="Country code" helperText="2-letter uppercase ISO country code" + errorMessage="Field is required" allowCustomValue items={['DE', 'FI', 'US']} /> diff --git a/src/main/java/com/vaadin/demo/component/combobox/ComboBoxValidation.java b/src/main/java/com/vaadin/demo/component/combobox/ComboBoxValidation.java index 0c64ec80e2..c49f689195 100644 --- a/src/main/java/com/vaadin/demo/component/combobox/ComboBoxValidation.java +++ b/src/main/java/com/vaadin/demo/component/combobox/ComboBoxValidation.java @@ -1,6 +1,7 @@ package com.vaadin.demo.component.combobox; import com.vaadin.flow.component.combobox.ComboBox; +import com.vaadin.flow.component.combobox.ComboBox.ComboBoxI18n; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.router.Route; import com.vaadin.demo.DemoExporter; // hidden-source-line @@ -15,6 +16,8 @@ public ComboBoxValidation() { ComboBox field = new ComboBox<>(); field.setRequiredIndicatorVisible(true); field.setAllowedCharPattern("[A-Z]"); + field.setI18n(new ComboBoxI18n() + .setRequiredErrorMessage("Field is required")); // end::snippet[] field.setLabel("Country code"); field.setHelperText("2-letter uppercase ISO country code");