tree value change listener

Hi all,

I have a trouble when I want to add a listener to a tree

I wanted to add the possibility of two items with the same caption, so I add the items as
here

The problem is my listener to a value change:

  addListener(new Property.ValueChangeListener() {

			public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
				if(event.getProperty().getValue() != null)
				{
					String caption= event.getProperty().getValue().toString();
				}
			}
		});

It works for items added as addItem(“Hello”), where I would receive “Hello” from event.getProperty().getValue(), but it’s null for items added as the link above.

Anyone knows how can I get the caption of the item selected from my valueChangeListener using the link way of adding items to the tree??

Thanks in advance and apologies for my english!

Hi, I’ve found how to do it

It’s as easy as use “getItemCaption” function, using as a paramether event.getProperty() value.

Here is my code

addListener(new Property.ValueChangeListener() {

			public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
				if(event.getProperty().getValue() != null)
				{
					String atribut = getItemCaption(event.getProperty().getValue()); // here we get the item caption
					System.out.println(atribut); //print
				}
			}
		});

Thank you all, I hope this would be usefull for someone!!