@Override
protected void setup(VaadinRequest request) {
final int totalRows = 100;
final VerticalLayout layout = new VerticalLayout();
final IndexedContainer datasource = new IndexedContainer();
datasource.addContainerProperty("value", Integer.class, -1);
for (int i = 0; i < totalRows; i++) {
addRow(datasource);
}
final Table table = new Table();
table.setContainerDataSource(datasource);
layout.addComponent(table);
addComponent(layout);
final Label label = new Label("");
layout.addComponent(label);
NativeButton addRowButton = new NativeButton("Add row",
new NativeButton.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
addRow(datasource);
}
});
NativeButton jumpToLastRowButton = new NativeButton("Jump to last row",
new NativeButton.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
jumpToLastRow(table);
}
});
NativeButton jumpTo15thRowButton = new NativeButton("Jump to 15th row",
new NativeButton.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
jumpToFifteenthRow(table);
}
});
NativeButton jumpToFirstRowButton = new NativeButton(
"Jump to first row", new NativeButton.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
jumpToFirstRow(table);
}
});
NativeButton updateLabelButton = new NativeButton("UpdateLabel",
new NativeButton.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
label.setValue(Integer.toString(table
.getCurrentPageFirstItemIndex()));
}
});
layout.addComponent(addRowButton);
layout.addComponent(jumpToLastRowButton);
layout.addComponent(jumpTo15thRowButton);
layout.addComponent(jumpToFirstRowButton);
layout.addComponent(updateLabelButton);
}