use of com.vaadin.flow.component.combobox.test.entity.Project in project flow-components by vaadin.
the class ComboBoxView method storingCustomValues.
private void storingCustomValues() {
Div message = createMessageDiv("custom-value-message");
ComboBox<Project> comboBox = new ComboBox<>("Project");
comboBox.setItems(this::fetchProjects, this::countProjects);
comboBox.setItemLabelGenerator(Project::getName);
comboBox.addValueChangeListener(valueChangeEvent -> {
if (valueChangeEvent.getValue() == null) {
message.setText("No project selected");
} else {
message.setText("Selected value: " + valueChangeEvent.getValue());
}
});
comboBox.addCustomValueSetListener(event -> {
Project project = projectData.addProject(event.getDetail());
comboBox.setValue(project);
});
addCard("Storing custom values", comboBox, message);
}
use of com.vaadin.flow.component.combobox.test.entity.Project in project flow-components by vaadin.
the class ProjectData method addProject.
public Project addProject(String name) {
int id = PROJECT_LIST.size() + 1;
Project newProject = new Project(id, name);
PROJECT_LIST.add(newProject);
return newProject;
}
use of com.vaadin.flow.component.combobox.test.entity.Project in project flow-components by vaadin.
the class ProjectData method createProjectList.
private List<Project> createProjectList() {
List<Project> projectList = new ArrayList<>();
projectList.add(new Project(1, "Apollo"));
projectList.add(new Project(2, "Aquarius"));
projectList.add(new Project(3, "Polar"));
return projectList;
}