You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SetCurrentPageFirstItemId.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.tests.components.TestBase;
  3. import com.vaadin.ui.Button;
  4. import com.vaadin.ui.VerticalLayout;
  5. import com.vaadin.v7.ui.Table;
  6. public class SetCurrentPageFirstItemId extends TestBase {
  7. int index = 0;
  8. private final Table table = new Table();
  9. @Override
  10. public void setup() {
  11. VerticalLayout mainLayout = new VerticalLayout();
  12. mainLayout.setHeight("100%");
  13. mainLayout.setMargin(true);
  14. getMainWindow().setContent(mainLayout);
  15. mainLayout.addComponent(table);
  16. table.setSizeFull();
  17. table.addContainerProperty("rowID", Integer.class, null);
  18. for (int i = 0; i < 20; i++) {
  19. addRow();
  20. }
  21. Button addrowButton = new Button("Add row");
  22. addrowButton.addClickListener(event -> {
  23. Object id = addRow();
  24. table.setCurrentPageFirstItemId(id);
  25. });
  26. mainLayout.addComponent(addrowButton);
  27. }
  28. private Object addRow() {
  29. return table.addItem(new Object[] { index++ }, null);
  30. }
  31. @Override
  32. protected String getDescription() {
  33. return "Table.setCurrentPageFirstItemId doesn't always work with full sized Table";
  34. }
  35. @Override
  36. protected Integer getTicketNumber() {
  37. return 7607;
  38. }
  39. }