Tree ItemClickListener not called until tree node expanded/collapsed

I have tried to follow the examples when creating a Tree (including a working one in the same application), but no matter what I do I get the same problem with the ItemClickListener: it is not triggered until a node (any node) in the tree is expanded or collapsed. Then the ItemClickListener is called, with the correct item.

Tree historyEventsTree = new Tree();
HierarchicalContainer treeContainer = new HierarchicalContainer();
treeContainer.addContainerProperty("title", String.class, null);

// Load treeContainer

historyEventsTree.addListener(new ItemClickListener() {
	private static final long serialVersionUID = 1L;
	public void itemClick(ItemClickEvent event) {
		if (event.getItem() != null) {
			Item clicked = event.getItem();
					(String) clicked.getItemProperty("title").getValue(), 

The only difference I can see between this tree and the one where the ItemClickListener works is that this non-functional one is added in BeanValidationForm. Is that why it won’t work? Am I doing some other stupid newbie mistake I’m blind to? And is there a way around the problem?

You need to set tree immediate

That is one of the things I have tried, but it doesn’t help for ItemClickListener unfortunately, only for ValueChangeEvent (well actually, I don’t receive any ValueChangeEvents at all, with or without immediate).

if you still haven’t found a solution, maybe you can post the whole code, so people can check what is wrong.

Problem solved. The Tree is on a Window. When I added an empty MouseEvents.ClickListener on the Window, the Tree ItemClickListener fires correctly.