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.

ComboBoxInvalidNullSelection.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package com.vaadin.tests.components.combobox;
  2. import com.vaadin.tests.components.TestBase;
  3. import com.vaadin.tests.util.Log;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.ComboBox;
  6. public class ComboBoxInvalidNullSelection extends TestBase {
  7. private boolean biggerData = true;
  8. private ComboBox<String> combo;
  9. private Log log = new Log(5);
  10. @Override
  11. protected void setup() {
  12. Button b = new Button("Swap data provider");
  13. b.addClickListener(event -> {
  14. if (biggerData) {
  15. combo.setItems("Item 3");
  16. } else {
  17. combo.setItems("Item 1", "Item 2", "Item 3", "Item 4");
  18. }
  19. biggerData = !biggerData;
  20. });
  21. combo = new ComboBox<>();
  22. combo.setItems("Item 1", "Item 2", "Item 3", "Item 4");
  23. combo.addValueChangeListener(
  24. event -> log.log("Value is now: " + combo.getValue()));
  25. addComponent(log);
  26. addComponent(b);
  27. addComponent(combo);
  28. addComponent(new Button("Dummy for TestBench"));
  29. }
  30. @Override
  31. protected String getDescription() {
  32. return "Select \"Item 3\" in the ComboBox, change the data provider, focus and blur the ComboBox. The value should temporarily change to null when changing data provider but not when focusing and blurring the ComboBox";
  33. }
  34. @Override
  35. protected Integer getTicketNumber() {
  36. return 6170;
  37. }
  38. }