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.

ListSelectJump.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package com.vaadin.tests.components.listselect;
  2. import java.util.ArrayList;
  3. import com.vaadin.server.VaadinRequest;
  4. import com.vaadin.shared.ui.ContentMode;
  5. import com.vaadin.shared.ui.MarginInfo;
  6. import com.vaadin.tests.components.AbstractReindeerTestUI;
  7. import com.vaadin.ui.Button;
  8. import com.vaadin.ui.Label;
  9. import com.vaadin.ui.ListSelect;
  10. public class ListSelectJump extends AbstractReindeerTestUI {
  11. @Override
  12. public void setup(VaadinRequest request) {
  13. getLayout().setMargin(new MarginInfo(true, false, false, false));
  14. addComponent(new Label(
  15. "Instructions:<ol><li>Select Option #1</li><li><b>Also</b> select Option #10 (use meta-click)</li>"
  16. + "<li>Leave the Option #10 visible in the scroll window</li><li>Press the button</li></ol>"
  17. + "You will see the <code>ListSelect</code> scroll window jump back to the top.",
  18. ContentMode.HTML));
  19. ArrayList<String> list = new ArrayList<>();
  20. for (int i = 1; i <= 25; i++) {
  21. list.add("Option #" + i);
  22. }
  23. ListSelect<String> listSelect = new ListSelect<>(null, list);
  24. listSelect.setRows(5);
  25. listSelect.setId("listselect");
  26. addComponent(listSelect);
  27. Button button = new Button("Press Me");
  28. button.setId("button");
  29. addComponent(button);
  30. }
  31. @Override
  32. protected String getTestDescription() {
  33. return "ListSelect jumps to top row after each client -> server contact";
  34. }
  35. @Override
  36. protected Integer getTicketNumber() {
  37. return 10416;
  38. }
  39. }