Search in sources :

Example 1 with SimpleBean

use of com.vaadin.flow.component.combobox.bean.SimpleBean in project flow-components by vaadin.

the class ComboBoxPage method setLabelGeneratorAfterValue.

private void setLabelGeneratorAfterValue() {
    ComboBox<SimpleBean> combo = new ComboBox<>();
    SimpleBean foo = new SimpleBean("foo");
    combo.setItems(foo);
    combo.setId("label-generator-after-value");
    combo.setValue(foo);
    combo.setItemLabelGenerator(SimpleBean::getName);
    add(combo);
}
Also used : ComboBox(com.vaadin.flow.component.combobox.ComboBox) SimpleBean(com.vaadin.flow.component.combobox.bean.SimpleBean)

Example 2 with SimpleBean

use of com.vaadin.flow.component.combobox.bean.SimpleBean in project flow-components by vaadin.

the class RefreshDataProviderPage method createRefreshItem.

private void createRefreshItem() {
    SimpleBean item1 = new SimpleBean("foo");
    SimpleBean item2 = new SimpleBean("bar");
    ComboBox<SimpleBean> comboBox = new ComboBox<>();
    comboBox.setItemLabelGenerator(SimpleBean::getName);
    comboBox.setId("refresh-item-combo-box");
    comboBox.setItems(item1, item2);
    NativeButton button = new NativeButton("Change both items, refresh only the second one", e -> {
        item1.setName("foo updated");
        item2.setName("bar updated");
        comboBox.getDataProvider().refreshItem(item2);
    });
    button.setId("refresh-item");
    add(comboBox, button);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) ComboBox(com.vaadin.flow.component.combobox.ComboBox) SimpleBean(com.vaadin.flow.component.combobox.bean.SimpleBean)

Aggregations

ComboBox (com.vaadin.flow.component.combobox.ComboBox)2 SimpleBean (com.vaadin.flow.component.combobox.bean.SimpleBean)2 NativeButton (com.vaadin.flow.component.html.NativeButton)1