use of com.vaadin.flow.component.crud.BinderCrudEditor in project flow-components by vaadin.
the class Helper method createPersonEditor.
static CrudEditor<Person> createPersonEditor() {
TextField firstName = new TextField("First name");
firstName.getElement().setAttribute("editor-role", "first-name");
TextField lastName = new TextField("Last name");
lastName.getElement().setAttribute("editor-role", "last-name");
FormLayout form = new FormLayout(firstName, lastName);
Binder<Person> binder = new Binder<>(Person.class);
binder.forField(firstName).asRequired().bind(Person::getFirstName, Person::setFirstName);
binder.forField(lastName).withValidator(value -> value != null && value.startsWith("O"), "Only last names starting with 'O' allowed").bind(Person::getLastName, Person::setLastName);
return new BinderCrudEditor<>(binder, form);
}
use of com.vaadin.flow.component.crud.BinderCrudEditor in project DoodleVerse by davidemarcoli.
the class CitizenManagementView method createEditor.
/**
* Create the CRUD Editor
* @return the CrudEditor
*/
private CrudEditor<Person> createEditor() {
TextField firstName = new TextField("First name");
TextField lastName = new TextField("Last name");
NumberField money = new NumberField("Money");
money.setReadOnly(true);
Double randomMoneyAmount = rand.nextDouble(100000 + 1 - 10000) + 10000;
money.setValue(randomMoneyAmount);
FormLayout form = new FormLayout(firstName, lastName, money);
form.setColspan(money, 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(money).asRequired().bind(Person::getMoney, Person::setMoney).setReadOnly(true);
return new BinderCrudEditor<>(binder, form);
}
use of com.vaadin.flow.component.crud.BinderCrudEditor in project docs by vaadin.
the class CrudBasic method createEditor.
private CrudEditor<Person> createEditor() {
TextField firstName = new TextField("First name");
TextField lastName = new TextField("Last name");
EmailField email = new EmailField("Email");
TextField profession = new TextField("Profession");
FormLayout form = new FormLayout(firstName, lastName, email, 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(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.crud.BinderCrudEditor in project docs by vaadin.
the class CrudEditorAside method createEditor.
private CrudEditor<Person> createEditor() {
TextField firstName = new TextField("First name");
TextField lastName = new TextField("Last name");
EmailField email = new EmailField("Email");
TextField profession = new TextField("Profession");
FormLayout form = new FormLayout(firstName, lastName, email, 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(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.crud.BinderCrudEditor 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);
}
Aggregations