Search in sources :

Example 1 with LocalDateToDateConverter

use of com.vaadin.flow.data.converter.LocalDateToDateConverter in project docs by vaadin.

the class CrudColumns method createEditor.

private CrudEditor<Person> createEditor() {
    TextField firstName = new TextField("First name");
    EmailField email = new EmailField("Email");
    TextField profession = new TextField("Profession");
    DatePicker birthday = new DatePicker("Birthday");
    FormLayout form = new FormLayout(firstName, email, profession, birthday);
    Binder<Person> binder = new Binder<>(Person.class);
    binder.forField(firstName).asRequired().bind(Person::getFirstName, Person::setFirstName);
    binder.forField(email).asRequired().bind(Person::getEmail, Person::setEmail);
    binder.forField(profession).asRequired().bind(Person::getProfession, Person::setProfession);
    binder.forField(birthday).asRequired().withConverter(new LocalDateToDateConverter()).bind(Person::getBirthday, Person::setBirthday);
    return new BinderCrudEditor<>(binder, form);
}
Also used : FormLayout(com.vaadin.flow.component.formlayout.FormLayout) Binder(com.vaadin.flow.data.binder.Binder) EmailField(com.vaadin.flow.component.textfield.EmailField) TextField(com.vaadin.flow.component.textfield.TextField) DatePicker(com.vaadin.flow.component.datepicker.DatePicker) BinderCrudEditor(com.vaadin.flow.component.crud.BinderCrudEditor) Person(com.vaadin.demo.domain.Person) LocalDateToDateConverter(com.vaadin.flow.data.converter.LocalDateToDateConverter)

Aggregations

Person (com.vaadin.demo.domain.Person)1 BinderCrudEditor (com.vaadin.flow.component.crud.BinderCrudEditor)1 DatePicker (com.vaadin.flow.component.datepicker.DatePicker)1 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)1 EmailField (com.vaadin.flow.component.textfield.EmailField)1 TextField (com.vaadin.flow.component.textfield.TextField)1 Binder (com.vaadin.flow.data.binder.Binder)1 LocalDateToDateConverter (com.vaadin.flow.data.converter.LocalDateToDateConverter)1