public class DocumentsList extends Table {
public DocumentsList() {
setContainerDataSource (DocumentsListDataSource.createWithTestData());
// setSelectable (true);
setVisibleColumns(DocumentsListDataSource.NATURAL_COL_ORDER);
setColumnHeaders(DocumentsListDataSource.COL_HEADERS_RU);
}
public void init() {
this.setSelectable (true);
}
}
The problem is when i try to initialize my DocumentsList table with the init() method which is called after a DocumentsList object got created, i can not select any table item clicking with the mouse. Although, the property selectable of DocumentsList is true.
If the init() method is called from the constructor, everything works fine.
public class TabletestApplication extends Application {
@Override
public void init() {
Window mainWindow = new Window("Tabletest Application");
DocumentsList list = new DocumentsList();
list.init();
mainWindow.addComponent(list);
setMainWindow(mainWindow);
}
public class DocumentsList extends Table {
public DocumentsList() {
IndexedContainer container = new IndexedContainer();
container.addContainerProperty("name", String.class, "");
container.addContainerProperty("somethingRandom", String.class, "baz");
Item item = container.addItem("foo");
item.getItemProperty("name").setValue("foo");
item = container.addItem("bar");
item.getItemProperty("name").setValue("bar");
setContainerDataSource (container);
setVisibleColumns(new Object[]{"name"});
setColumnHeaders(new String[]{"Item name"});
}
public void init() {
this.setSelectable (true);
}
}
}
I tested that with Vaadin versions 6.3.4 and a 6.4 nightly. No probelms in selecting the rows. Additionally, I don’t see that it should matter if you call init as the last row in the constructor or as the first row after a “new DocumentsList()”. They should basically be the same. Can there be some other code affecting the behaviour somewhere? Try to reproduce the problem in a separate application with the minimum amount of code.
Yeah Jens, you’re right. It was my fault. The problem was in that at some step of objects wiring, the system got another object which actually was not effected with setSelectable().