use of com.vaadin.flow.component.formlayout.FormLayout in project docs by vaadin.
the class CrudEditorContent method createEditor.
// tag::snippet2[]
private CrudEditor<Person> createEditor() {
TextField firstName = new TextField("First name");
TextField lastName = new TextField("Last name");
EmailField email = new EmailField("Email");
ComboBox<String> profession = new ComboBox<>("Profession");
profession.setItems(professions);
FormLayout form = new FormLayout(firstName, lastName, email, profession);
form.setColspan(email, 2);
form.setColspan(profession, 2);
form.setMaxWidth("480px");
form.setResponsiveSteps(new FormLayout.ResponsiveStep("0", 1), new FormLayout.ResponsiveStep("30em", 2));
Binder<Person> binder = new Binder<>(Person.class);
binder.forField(firstName).asRequired().bind(Person::getFirstName, Person::setFirstName);
binder.forField(lastName).asRequired().bind(Person::getLastName, Person::setLastName);
binder.forField(email).asRequired().bind(Person::getEmail, Person::setEmail);
binder.forField(profession).asRequired().bind(Person::getProfession, Person::setProfession);
return new BinderCrudEditor<>(binder, form);
}
use of com.vaadin.flow.component.formlayout.FormLayout in project docs by vaadin.
the class CrudSortingFiltering method createEditor.
private CrudEditor<Person> createEditor() {
TextField firstName = new TextField("First name");
TextField lastName = new TextField("Last name");
TextField profession = new TextField("Profession");
FormLayout form = new FormLayout(firstName, lastName, profession);
Binder<Person> binder = new Binder<>(Person.class);
binder.forField(firstName).asRequired().bind(Person::getFirstName, Person::setFirstName);
binder.forField(lastName).asRequired().bind(Person::getLastName, Person::setLastName);
binder.forField(profession).asRequired().bind(Person::getProfession, Person::setProfession);
return new BinderCrudEditor<>(binder, form);
}
use of com.vaadin.flow.component.formlayout.FormLayout in project komunumo-server by komunumo.
the class MembersView method createFeedbackForm.
private Component createFeedbackForm() {
final var div = new Div();
div.addClassName("feedback-form");
div.add(new H2("Your Feedback, suggestion, idea..."));
final var firstName = new TextField("First name");
firstName.setMinLength(1);
firstName.setMaxLength(2_000);
final var lastName = new TextField("Last name");
lastName.setMinLength(1);
lastName.setMaxLength(2_000);
final var email = new EmailField("Email");
email.setMinLength(1);
email.setMaxLength(2_000);
final var feedback = new TextArea("Feedback");
feedback.setMinLength(1);
feedback.setMaxLength(2_000);
final var submit = new Button("Send");
submit.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
submit.setEnabled(false);
submit.setDisableOnClick(true);
List.of(firstName, lastName, email, feedback).forEach(field -> {
field.setRequiredIndicatorVisible(true);
field.setValueChangeMode(ValueChangeMode.EAGER);
field.addValueChangeListener(valueChangeEvent -> submit.setEnabled(!firstName.getValue().isBlank() && !lastName.getValue().isBlank() && !email.isInvalid() && !feedback.getValue().isBlank()));
});
final var form = new FormLayout();
form.setResponsiveSteps(new FormLayout.ResponsiveStep("0", 1));
form.add(firstName, lastName, email, feedback, submit);
div.add(form);
submit.addClickListener(buttonClickEvent -> {
databaseService.receiveFeedback(firstName.getValue(), lastName.getValue(), email.getValue(), feedback.getValue());
div.replace(form, new Paragraph("We have received your feedback, thank you very much!"));
});
firstName.focus();
return div;
}
use of com.vaadin.flow.component.formlayout.FormLayout in project linkki by linkki-framework.
the class OverflowIssues method requiredIndicatorWithEmptyLabel.
private void requiredIndicatorWithEmptyLabel() {
add(new Label("This layout must not have a scrollbar:"));
FormLayout formLayout = new FormLayout();
FormItem formItem = formLayout.addFormItem(new Label("Ich bin ein Label ohne Label"), "");
formItem.getStyle().set("overflow", "auto");
add(formLayout);
}
use of com.vaadin.flow.component.formlayout.FormLayout in project linkki by linkki-framework.
the class UIFormLayoutIntegrationTest method testCreation.
@Test
void testCreation() {
BindingContext bindingContext = new BindingContext();
FormLayoutPmo pmo = new FormLayoutPmo();
Component component = VaadinUiCreator.createComponent(pmo, bindingContext);
assertThat("UiCreator should be able to create a FormLayout", component, is(instanceOf(FormLayout.class)));
FormLayout layout = (FormLayout) component;
assertThat("Child component should be correctly created", layout.getChildren().count(), is(1L));
assertThat("Child component should be correctly created", layout.getChildren().findFirst().get(), is(instanceOf(TextField.class)));
TextField textField = (TextField) layout.getChildren().findFirst().get();
pmo.setText("new text");
bindingContext.modelChanged();
assertThat("Child components should be correctly bound", textField.getValue(), is("new text"));
}
Aggregations