}
@Override
protected void setup() {
Layout l = getLayout();
populateContainer(hier);
// sort(indexedContainer);
tree1 = new Tree("Tree with wrapped IndexedContainer");
tree1.setContainerDataSource(hier);
tree1.setItemCaptionPropertyId("name");
for (Object id : hier.rootItemIds()) {
tree1.expandItemsRecursively(id);
}
l.addComponent(tree1);
// This contains a bug, changes not reflected back to client
Button modify = new Button("Modify and sort (has a bug)",
new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
// Get first item
Object itemId = indexedContainer.getIdByIndex(0);
Item item = indexedContainer.getItem(itemId);
Property<String> property = item
.getItemProperty("name");
// Prepend with Z so item should get sorted later
property.setValue("Z " + property.getValue());
// this does not work alone, requires extraneous
// setContainerDataSource for server-side changes to be
// reflected back to client-side
sort(indexedContainer);
}
});
l.addComponent(modify);
Table t = new Table("Table with indexed container", indexedContainer);
l.addComponent(t);
}