Search in sources :

Example 76 with TextField

use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.

the class BindPlaceholderIntegrationTest method testAspectBindPlaceholderAnnotation_DynamicEmptyValue.

@Test
void testAspectBindPlaceholderAnnotation_DynamicEmptyValue() {
    TextField textfield = (TextField) uiElements.get("placeholderFieldDynamic");
    pmo.setPlaceholder("");
    bindingContext.modelChanged();
    String placeholderResult = textfield.getPlaceholder();
    assertThat(placeholderResult).isEmpty();
}
Also used : UITextField(org.linkki.core.ui.element.annotation.UITextField) TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Example 77 with TextField

use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.

the class BindPlaceholderIntegrationTest method testAspectBindPlaceholderAnnotation_NotBound.

@Test
void testAspectBindPlaceholderAnnotation_NotBound() {
    TextField textfield = (TextField) uiElements.get("notBoundPlaceholderField");
    String placeholderResult = textfield.getPlaceholder();
    assertThat(placeholderResult).isNull();
}
Also used : UITextField(org.linkki.core.ui.element.annotation.UITextField) TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Example 78 with TextField

use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.

the class DefaultErrorDialog method createRootCauseTextField.

private static TextField createRootCauseTextField(@CheckForNull Throwable t) {
    TextField textField = new TextField(NlsText.getString("DefaultErrorHandler.errorDialogDescription"));
    String message = Optional.ofNullable(ExceptionUtils.getRootCause(t)).map(Throwable::getLocalizedMessage).orElse(ExceptionUtils.getRootCauseMessage(t));
    textField.setValue(message);
    formatText(textField);
    return textField;
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField)

Example 79 with TextField

use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.

the class UIDoubleFieldIntegrationTest method testSetValue_WithPrimitiveDoubleInModelObject.

@Test
void testSetValue_WithPrimitiveDoubleInModelObject() {
    TestModelObjectWithPrimitiveDouble modelObject = new TestModelObjectWithPrimitiveDouble();
    TextField textField = createFirstComponent(modelObject);
    assertThat(textField.getMaxLength(), is(MAX_LENGTH));
    assertThat(textField.getValue(), is(formatter.format(0.0)));
    TestUiUtil.setUserOriginatedValue(textField, formatter.format(1.0));
    assertThat(modelObject.getValue(), is(1.0));
    modelObject.setValue(2.0);
    getBindingContext().modelChanged();
    assertThat(textField.getValue(), is(formatter.format(2.0)));
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Example 80 with TextField

use of com.vaadin.flow.component.textfield.TextField in project linkki by linkki-framework.

the class UIDoubleFieldIntegrationTest method testSetValue_WithObjectDoubleInModelObject.

@Test
void testSetValue_WithObjectDoubleInModelObject() {
    TestModelObjectWithObjectDouble modelObject = new TestModelObjectWithObjectDouble();
    TextField textField = createFirstComponent(modelObject);
    assertThat(textField.getValue(), is(emptyString()));
    TestUiUtil.setUserOriginatedValue(textField, formatter.format(1.0));
    assertThat(modelObject.getValue(), is(1.0));
    modelObject.setValue(2.0);
    getBindingContext().modelChanged();
    assertThat(textField.getValue(), is(formatter.format(2.0)));
    TestUiUtil.setUserOriginatedValue(textField, textField.getEmptyValue());
    assertThat(modelObject.getValue(), is(nullValue()));
}
Also used : TextField(com.vaadin.flow.component.textfield.TextField) Test(org.junit.jupiter.api.Test)

Aggregations

TextField (com.vaadin.flow.component.textfield.TextField)227 Test (org.junit.jupiter.api.Test)61 Button (com.vaadin.flow.component.button.Button)54 Div (com.vaadin.flow.component.html.Div)38 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)32 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)29 Binder (com.vaadin.flow.data.binder.Binder)29 GeneratedVaadinTextField (com.vaadin.flow.component.textfield.GeneratedVaadinTextField)28 Element (com.vaadin.flow.dom.Element)26 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)23 Route (com.vaadin.flow.router.Route)21 Component (com.vaadin.flow.component.Component)16 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)15 BinderCrudEditor (com.vaadin.flow.component.crud.BinderCrudEditor)15 Grid (com.vaadin.flow.component.grid.Grid)15 Span (com.vaadin.flow.component.html.Span)15 List (java.util.List)15 EmailField (com.vaadin.flow.component.textfield.EmailField)14 TextArea (com.vaadin.flow.component.textfield.TextArea)14 Test (org.junit.Test)14