Search code examples
comboboxwindowvaadinvaadin7

Update combobox in window 1 after updating window2 Vaadin


I have a Vaadin window1 which contains a ComboBox of items from database. When I select an item of this ComboBox I have a window2 which appears. This window2 gives me the possibility to add data in database. Now I want to see the new item in my ComboBox in window1 after closing window2. Have you any idea please how to achieve that?


Solution

  • You need to refresh the container data source. In my case, I had a JPAContainer that has a refresh() method, see documentation. If you use SQLContainer then have a look at its documentation.

    If you use no special container but the ComboBox method addItem, then you should call removeAllItems and add the new items (by performing the DB query again).