Table items selection with double click.

Hello,

I use double click on table to open window for item editing with the following code:

myTable.addListener(new ItemClickListener()	{
			public void itemClick(ItemClickEvent event) {
				if (event.isDoubleClick())	{
					MyItem item = (MyItem) event.getItemId();
					EditWindow window = new EditWindow(item);
                                        ...
				}
			}
        });

It works fine, but when click listener exits, item selection is lost and no item in table left selected.
Any ideas, how to keep selection on double clicked item?

Thanks, Andrew.

Maybe something like this: [code]

table.addListener(new ItemClickEvent.ItemClickListener() {
public void itemClick(ItemClickEvent event) {
if (event.isDoubleClick()) {
((Table) event.getSource()).select(event.getItemId());
}
}
});

[/code]

Thank you for reply.

However this code does not solves the problem because double cliked item is selected when listener runs (this could be verified both visually an by calling table.getValue()) but loses selection when listener exits.

I removed all custom code from listener and tested exactly the suggested fragment, result is the same - no item left selected after double click.

Andrew.

According to the book of Vaadin, you can use
table.setNullSelectionAllowed(false)
and you won’t lose the selection on the second click.