Hi everyone and happy new year!
I am still training to use Vaadin. There is 3 comboboxes in my page (to select country then city and then company).
There is COMPANY(table), which includes Address and it includes City and Country etc. In one country can have n cities and in one city can have n addresses.
I am using JPAContainer and JPAContainerCustomField. First user choose a country and after that cities combobox should be repopulated. After that user choose a city and Cities combobox should be repopulated and at last user choose a company and remember that company has Address.
Could someone give me a link to nice example or tell me what is the wisest way to handle this with JPA and comboboxes.
public CountrySelector() {
cityContainer = JPAContainerFactory.make(City.class,
BazookaCalendarApplication.PERSISTENCE_UNIT);
countryContainer = JPAContainerFactory.make(Country.class,
BazookaCalendarApplication.PERSISTENCE_UNIT);
setCaption("Country");
city.setContainerDataSource(cityContainer);
city.setItemCaptionPropertyId("city");
city.setImmediate(true);
countryContainer.setApplyFiltersImmediately(false);
country.setContainerDataSource(countryContainer);
country.setItemCaptionPropertyId("country");
country.addListener(new Property.ValueChangeListener() {
public void valueChange(
com.vaadin.data.Property.ValueChangeEvent event) {
/*
* Modify the actual value of the custom field.
*/
if (country.getValue() == null) {
setValue(null, false);
} else {
Country countryEntity = countryContainer
.getItem(country.getValue()).getEntity();
Any ideas? Shoud I just use country’s cities (countryEntity.getCities())or is there some another way, filters or should I just use JPQL etc?
Thanks
Sami