I have a question about vaadin 8. I have a view with a central dynamic part(_filteredContentVL) that depends on a comboBox (_serviceSelectionCmb )selection. With a ValueChangeListener I tried to rebuild the central part (_filteredContentVL=buildFilteredContent() but I don’t know how to refresh the page or to change and refresh the content of the _filteredContentVL component. Any ideas?
_root = new VerticalLayout();
_filteredContentVL = new VerticalLayout(buildFilteredContent());
_root.addComponent(buildSelection());
_root.addComponent(_filteredContentVL);
...
private Component buildServiceSelection() {
_serviceSelectionCmb.setItems(Arrays.asList(ProjectsSelectionType.x,
ProjectsSelectionType.y, ProjectsSelectionType.z));
_serviceSelectionCmb.setEmptySelectionAllowed(false);
_serviceSelectionCmb.setValue(ProjectsSelectionType.x);
_serviceSelectionCmb.addValueChangeListener(event -> {
_filteredContentVL=buildFilteredContent();
}
});
}
...
...
private VerticalLayout buildFilteredContent() {
VerticalLayout contentVL = new VerticalLayout();
switch (_serviceSelectionCmb.getValue()) {
case ProjectsSelectionType.x:
contentVL.addComponent(new CSProjectsView());
break;
case ProjectsSelectionType.y:
contentVL.addComponent(new IMProjectsView());
break;
case ProjectsSelectionType.z:
contentVL.addComponent(new BPProjectsView());
break;
default:
contentVL.addComponent(new CSProjectsView());
break;
}
return contentVL;
}