use of com.vaadin.flow.component.combobox.bean.TestItem in project flow-components by vaadin.
the class DataProviderPage method createDataProviderWithoutGetId.
private void createDataProviderWithoutGetId() {
add(new Hr());
ComboBox<TestItem> comboBoxWithoutGetId = new ComboBox<>();
comboBoxWithoutGetId.setId(COMBO_BOX_WITHOUT_GET_ID_ID);
comboBoxWithoutGetId.setItems(list);
add(comboBoxWithoutGetId);
NativeButton setValueUsingReferenceButton = new NativeButton("Set Value Using Reference", event -> comboBoxWithoutGetId.setValue(list.get(1)));
setValueUsingReferenceButton.setId(SET_VALUE_USING_REFERENCE_BUTTON_ID);
add(setValueUsingReferenceButton);
NativeButton setValueUsingEqualsButton = new NativeButton("Set Value Using Equals", event -> comboBoxWithoutGetId.setValue(new TestItem(4, "c", "")));
setValueUsingEqualsButton.setId(SET_VALUE_USING_EQUALS_BUTTON_ID);
add(setValueUsingEqualsButton);
}
use of com.vaadin.flow.component.combobox.bean.TestItem in project flow-components by vaadin.
the class DataProviderPage method createDataProviderWithGetId.
private void createDataProviderWithGetId() {
ComboBox<TestItem> comboBoxWithGetId = new ComboBox<>();
comboBoxWithGetId.setId(COMBO_BOX_WITH_GET_ID_ID);
comboBoxWithGetId.setDataProvider(new ListDataProvider<TestItem>(list) {
@Override
public Object getId(TestItem item) {
return item.getId();
}
});
add(comboBoxWithGetId);
NativeButton setValueUsingIdButton = new NativeButton("Set Value Using Id", event -> comboBoxWithGetId.setValue(new TestItem(2)));
setValueUsingIdButton.setId(SET_VALUE_USING_GET_ID_BUTTON_ID);
add(setValueUsingIdButton);
}
use of com.vaadin.flow.component.combobox.bean.TestItem in project flow-components by vaadin.
the class RequiredComboboxPage method requiredComboBoxSetItemsAfter.
private void requiredComboBoxSetItemsAfter() {
Binder<TestItem> binder = new Binder<>();
ComboBox<String> comboBox = new ComboBox<>();
binder.forField(comboBox).asRequired().bind(TestItem::getName, TestItem::setName);
binder.setBean(new TestItem(0));
// Set items last:
comboBox.setItems("foo", "bar");
add(comboBox);
}
Aggregations