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.

ComboBoxSelecting.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package com.vaadin.tests.components.combobox;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import com.vaadin.annotations.Widgetset;
  5. import com.vaadin.server.VaadinRequest;
  6. import com.vaadin.tests.components.AbstractReindeerTestUI;
  7. import com.vaadin.ui.ComboBox;
  8. import com.vaadin.ui.Label;
  9. import com.vaadin.ui.TextField;
  10. @Widgetset("com.vaadin.DefaultWidgetSet")
  11. public class ComboBoxSelecting extends AbstractReindeerTestUI {
  12. protected ComboBox<String> comboBox;
  13. protected List<String> items = new ArrayList<>();
  14. @Override
  15. protected void setup(VaadinRequest request) {
  16. for (char c = 'a'; c <= 'z'; c++) {
  17. for (int i = 0; i < 100; i++) {
  18. items.add("" + c + i);
  19. }
  20. }
  21. comboBox = new ComboBox<>(null, items);
  22. final Label label = new Label();
  23. label.setId("value");
  24. comboBox.setTextInputAllowed(true);
  25. comboBox.setEmptySelectionAllowed(true);
  26. comboBox.addValueChangeListener(event -> {
  27. String value = event.getValue();
  28. if (value != null) {
  29. label.setValue(value);
  30. } else {
  31. label.setValue("null");
  32. }
  33. });
  34. // Had to add an extra text field for our old Firefox browsers, because
  35. // tab will otherwise send the focus to address bar and FF 24 won't fire
  36. // a key event properly. Nice!
  37. addComponents(comboBox, label, new TextField());
  38. }
  39. @Override
  40. protected String getTestDescription() {
  41. return "Clearing the filter and hitting enter should select the null item";
  42. }
  43. @Override
  44. protected Integer getTicketNumber() {
  45. return 15502;
  46. }
  47. }