How to update a tree after modifying a BeanItem

The question is: given a Tree which has as datasource a HierarchicalContainer of BeanItems, if the BeanItem is modified shouldn’t the corresponding node from the tree be modified? Please see also the comments in the button click event below.


package com.example.treetest;

import com.vaadin.Application;
import com.vaadin.data.Item;
import com.vaadin.data.util.BeanItem;
import com.vaadin.data.util.HierarchicalContainer;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

public class TreetestApplication extends Application  {

	private static final long serialVersionUID = -81681775082687081L;

	
	@Override
	public void init() {
		Window mainWindow = new Window("Treetest Application");

		final HierarchicalContainer container = new HierarchicalContainer();
		final Tree tree = new Tree();
		Button b = new Button("change");
		
		String data[] = { "A", "B", "C", "D" };
		
		container.addContainerProperty("name", String.class, null);
		for( String d: data ){
			Item i = container.addItem(new BeanItem<Pers>( new Pers(d)));
			i.getItemProperty("name").setValue(d);
		}
		
		tree.setContainerDataSource(container);
		tree.setItemCaptionPropertyId("name");
		tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY );
		
		
		b.addListener(new ClickListener() {
	   	private static final long serialVersionUID = -3960905557130070582L;

			public void buttonClick(ClickEvent event) {
				BeanItem<Pers> pi = (BeanItem<Pers>) container.getIdByIndex(0);
				pi.getItemProperty("name").setValue("UVW"); //this is how it should be, but instead...
				//... I neede to do this...
				//Item pi = container.getItem( container.getItemIds().iterator().next() );
				//pi.getItemProperty("name").setValue("XYZ");
				//...which is of no use for me since I need to work on the BeanItem, and if that doesn't work I could as well drop the...
				//...BeanItem thing and work directly with the Pers, right?
				//   Is there a way to hook the Pers object with the node in the tree so I don't have to make two assignments for that name?
	        }
	    });
		
		mainWindow.addComponent(tree);
		mainWindow.addComponent(b);
		setMainWindow(mainWindow);
	}

}

package com.example.treetest;

public class Pers {
	private String name;

	public Pers( String n ){
		name = n;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}