Reputation: 407
I`ve added my own objects into a vaadin tree like this:
Item item = container.addItem(planet); //where planet is from class Planet
If I get it right, only the string taken from planet.toString() will be added to my tree.
Now I need to access several methods/attributes of my object (e.g. getMoons() or getPlanetID()). How can I access my object by selecting this planet in my tree (via getValue() in my valueChanged-event) ?
Upvotes: 1
Views: 1968
Reputation: 2766
Try this:
Planet myPlanet = (Planet) myTree.getValue();
myPlanet.getMoons();
Since the itemId
is an instance of Planet, you can safely cast the getValue()
result into such.
If you need the container in some other context, check BeanItemContainer out.
Upvotes: 2