Search in sources :

Example 1 with Person

use of com.vaadin.demo.domain.Person 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);
}
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) BinderCrudEditor(com.vaadin.flow.component.crud.BinderCrudEditor) Person(com.vaadin.demo.domain.Person)

Example 2 with Person

use of com.vaadin.demo.domain.Person 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);
}
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) BinderCrudEditor(com.vaadin.flow.component.crud.BinderCrudEditor) Person(com.vaadin.demo.domain.Person)

Example 3 with Person

use of com.vaadin.demo.domain.Person 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);
}
Also used : FormLayout(com.vaadin.flow.component.formlayout.FormLayout) Binder(com.vaadin.flow.data.binder.Binder) ComboBox(com.vaadin.flow.component.combobox.ComboBox) EmailField(com.vaadin.flow.component.textfield.EmailField) TextField(com.vaadin.flow.component.textfield.TextField) BinderCrudEditor(com.vaadin.flow.component.crud.BinderCrudEditor) Person(com.vaadin.demo.domain.Person)

Example 4 with Person

use of com.vaadin.demo.domain.Person 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);
}
Also used : FormLayout(com.vaadin.flow.component.formlayout.FormLayout) Binder(com.vaadin.flow.data.binder.Binder) TextField(com.vaadin.flow.component.textfield.TextField) BinderCrudEditor(com.vaadin.flow.component.crud.BinderCrudEditor) Person(com.vaadin.demo.domain.Person)

Example 5 with Person

use of com.vaadin.demo.domain.Person in project docs by vaadin.

the class CrudToolbar method setupToolbar.

private void setupToolbar() {
    // tag::snippet[]
    Html total = new Html("<span>Total: <b>" + dataProvider.DATABASE.size() + "</b> employees</span>");
    Button button = new Button("New employee", VaadinIcon.PLUS.create());
    button.addClickListener(event -> {
        crud.edit(new Person(), Crud.EditMode.NEW_ITEM);
    });
    button.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
    HorizontalLayout toolbar = new HorizontalLayout(total, button);
    toolbar.setAlignItems(FlexComponent.Alignment.CENTER);
    toolbar.setFlexGrow(1, toolbar);
    toolbar.setJustifyContentMode(FlexComponent.JustifyContentMode.BETWEEN);
    toolbar.setSpacing(false);
    crud.setToolbar(toolbar);
// end::snippet[]
}
Also used : Button(com.vaadin.flow.component.button.Button) Html(com.vaadin.flow.component.Html) Person(com.vaadin.demo.domain.Person) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Aggregations

Person (com.vaadin.demo.domain.Person)16 BinderCrudEditor (com.vaadin.flow.component.crud.BinderCrudEditor)12 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)12 TextField (com.vaadin.flow.component.textfield.TextField)12 Binder (com.vaadin.flow.data.binder.Binder)12 EmailField (com.vaadin.flow.component.textfield.EmailField)9 Button (com.vaadin.flow.component.button.Button)3 ComboBox (com.vaadin.flow.component.combobox.ComboBox)3 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)3 Grid (com.vaadin.flow.component.grid.Grid)2 DemoExporter (com.vaadin.demo.DemoExporter)1 DataService (com.vaadin.demo.domain.DataService)1 Html (com.vaadin.flow.component.Html)1 ButtonVariant (com.vaadin.flow.component.button.ButtonVariant)1 DatePicker (com.vaadin.flow.component.datepicker.DatePicker)1 Div (com.vaadin.flow.component.html.Div)1 Icon (com.vaadin.flow.component.icon.Icon)1 VaadinIcon (com.vaadin.flow.component.icon.VaadinIcon)1 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)1 LocalDateToDateConverter (com.vaadin.flow.data.converter.LocalDateToDateConverter)1