hide/show values in native select based on a condition

Can I hide/show values in native select based on a condition or other value…
I have a string value and i need to show only certain options in the dropdown if that string value equals for ex : XXXX and hide the options for all other values…

Can I do that in vaadin 7…

Thank you very much,


where does your string value come from? Maybe you can add some kind of listener to listen for events on your string value changing, and based on that modify the contents (container) of the NativeSelect. As for the hiding, I don’t think there’s support for that in the container or native select, apart from the filtering api of course but that may or may not be usable in your case.

Thank you Teppo,
The string value comes from another dropdown. I have to filter out the values in this dropdown based on the value i got from it. This is ok, but the problem is they are two different objects(components) and created in two different classes.

I have figured it out. I have changed my class design a bit and changed the container datasource based on the string value.

dropDown.setContainerDataSource(new IndexedContainer(listOfValues));

It works now.
Thank you