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.

TableJumpUI.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractTestUIWithLog;
  4. import com.vaadin.v7.data.util.BeanItemContainer;
  5. import com.vaadin.v7.ui.Table;
  6. import com.vaadin.v7.ui.TextField;
  7. /**
  8. * Test for ensuring page doesn't jump up to the Table selection on IE with
  9. * these steps:
  10. *
  11. * <p>
  12. * 1. refresh page <br>
  13. * 2. click within URL bar <br>
  14. * 3. click a table row to select it <br>
  15. * 4. click within one of the text fields <br>
  16. * 5. scroll down <br>
  17. * 6. click the button
  18. * </p>
  19. * The problem is that IE for some reason does not fire a blur event for the
  20. * table at step 4, leading to table thinking it is focused when it is updated
  21. * in step 6.
  22. *
  23. * @author Vaadin Ltd
  24. */
  25. public class TableJumpUI extends AbstractTestUIWithLog {
  26. @Override
  27. protected void setup(VaadinRequest request) {
  28. BeanItemContainer<TestObj> container = new BeanItemContainer<>(
  29. TestObj.class);
  30. for (int i = 0; i < 2; i++) {
  31. container.addBean(new TestObj(i));
  32. }
  33. final Table table = new Table();
  34. table.setPageLength(2);
  35. table.setContainerDataSource(container);
  36. table.setSelectable(true);
  37. addComponent(table);
  38. // After the table we have a lot of textfields so that we have to scroll
  39. // down to the button
  40. for (int i = 0; i < 40; i++) {
  41. TextField tf = new TextField();
  42. tf.setValue(String.valueOf(i));
  43. final int j = i;
  44. tf.addFocusListener(event -> log("Tf " + j + " focus"));
  45. tf.addBlurListener(event -> log("Tf " + j + " Blur"));
  46. addComponent(tf);
  47. }
  48. addButton("refresh row cache", event -> table.refreshRowCache());
  49. }
  50. @Override
  51. protected String getTestDescription() {
  52. return "Page shouldn't scroll up to Table selection when the button is clicked.";
  53. }
  54. @Override
  55. protected Integer getTicketNumber() {
  56. return 19676;
  57. }
  58. public static class TestObj {
  59. int i;
  60. String text;
  61. public TestObj(final int i) {
  62. this.i = i;
  63. text = "Object " + i;
  64. }
  65. public int getI() {
  66. return i;
  67. }
  68. public void setI(final int i) {
  69. this.i = i;
  70. }
  71. public String getText() {
  72. return text;
  73. }
  74. public void setText(final String text) {
  75. this.text = text;
  76. }
  77. }
  78. }