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.

ScrollCausesRequestLoop.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package com.vaadin.tests.components.table;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import com.vaadin.tests.components.AbstractTestCase;
  5. import com.vaadin.tests.util.Person;
  6. import com.vaadin.ui.HorizontalLayout;
  7. import com.vaadin.ui.LegacyWindow;
  8. import com.vaadin.v7.data.util.BeanItemContainer;
  9. import com.vaadin.v7.ui.Table;
  10. public class ScrollCausesRequestLoop extends AbstractTestCase {
  11. @Override
  12. public void init() {
  13. setMainWindow(new LegacyWindow("", new TestView()));
  14. }
  15. @Override
  16. protected String getDescription() {
  17. return "Scrolling a table causes an infinite loop of UIDL requests in some cases";
  18. }
  19. @Override
  20. protected Integer getTicketNumber() {
  21. return 8040;
  22. }
  23. private static class TestView extends HorizontalLayout {
  24. TestView() {
  25. Table table = new Table();
  26. List<Person> data = createData();
  27. BeanItemContainer<Person> container = new BeanItemContainer<Person>(
  28. Person.class, data) {
  29. @Override
  30. public Person getIdByIndex(int index) {
  31. try {
  32. // Simulate some loading delay with some exaggeration
  33. // to make easier to reproduce
  34. Thread.sleep(50);
  35. } catch (InterruptedException e) {
  36. Thread.currentThread().interrupt();
  37. throw new RuntimeException(e);
  38. }
  39. return super.getIdByIndex(index);
  40. }
  41. };
  42. table.setContainerDataSource(container);
  43. addComponent(table);
  44. }
  45. }
  46. private static List<Person> createData() {
  47. int count = 500;
  48. List<Person> data = new ArrayList<>(count);
  49. for (int i = 0; i < count; i++) {
  50. data.add(new Person("Person", "" + i, "Email", "Phone", "Street",
  51. 12345, "City"));
  52. }
  53. return data;
  54. }
  55. }