CustomField/JPAContainerCustomField, catching events and usage?


I’ve got mainview and CountrySelector (JPAContainerCustomField) is part of it.

In MainView-java:

    HorizontalLayout searchPanel = new HorizontalLayout();
    searchPanel.addComponent(new CountrySelector());

In CountrySelector I’ve got three dropBoxes and one button to search companies (Country-cities-companies):

public class CountrySelector extends JPAContainerCustomField implements ClickListener {
private JPAContainer cities;
private JPAContainer products;
private JPAContainer companies;
private JPAContainer countries;
private ComboBox countrySelect;
private ComboBox productSelect;
private ComboBox citySelect;
private Button searchButton;

countrySelect.addListener(new ValueChangeListener() {

		    public void valueChange( event) {
		        // Get the entity object of the selected row
		        Object itemId = event.getProperty().getValue();
		        EntityItem<Country> item = countries.getItem(itemId);
		        Country country = item.getEntity();
		        setValue(country, false);
	        	getWindow().showNotification("Selected country: " + country.getCountry());

and the Question is:

How can I get information of events to the mainview or everything what user has chosen in that searchPanel? Mainview should be reloaded after user selection in searchPanel.

Thanks a lot!
Sami :frowning:


CustomField is a property like other fields. It is designed to encapsulate a bunch of UI elements that can be used to select value for one property. E.g. if your item has an “office” property, your custom field could have “filtering selects” continent and country and then the actual office select that defines the value of the custom field. It won’t help you a bit unless you are using it in e.g. a Form so that one property of an item is bound to your custom field. If you are not using it as a Vaadin Field, you are most likely better of by just extending a layout or CustomComponent and the needed APIs like getSelectedCountry/Product/City in your case.

JPAContainer has its own version, but solely due to the fact that we have failed to include it in the core. It should have been done years ago when I created the first version of it while prototyping the Directory project.