public DepartmentSelector() { setImmediate(false); // conu = SpringApplicationContext.getContainerUtils(); container = conu.createJPABatchableContainer(Department.class); geoContainer = conu.createJPABatchableContainer(Department.class); geoContainer.setAutoCommit(false); container.setAutoCommit(false); setCaption("Department"); // Only list "roots" which are in our example geographical super // departments geoContainer.addContainerFilter(new IsNull("parent")); geographicalDepartment.setContainerDataSource(geoContainer); geographicalDepartment.setItemCaptionPropertyId("name"); geographicalDepartment.setImmediate(true); container.setApplyFiltersImmediately(false); filterDepartments(null); department.setContainerDataSource(container); department.setItemCaptionPropertyId("name"); geographicalDepartment.addListener( new Property.ValueChangeListener() { @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { /* * Modify filtering of the department combobox */ EntityItem<Department> item = geoContainer.getItem(geographicalDepartment.getValue()); Department entity = item.getEntity(); filterDepartments(entity); } }); department.addListener( new Property.ValueChangeListener() { @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { /* * Modify the actual value of the custom field. */ if (department.getValue() == null) { setValue(null, false); } else { Department entity = container.getItem(department.getValue()).getEntity(); setValue(entity, false); } } }); }