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.

TextFieldWithDataSourceAndInputPrompt.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.vaadin.tests.components.textfield;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractReindeerTestUI;
  4. import com.vaadin.v7.data.util.BeanItem;
  5. import com.vaadin.v7.ui.TextField;
  6. public class TextFieldWithDataSourceAndInputPrompt
  7. extends AbstractReindeerTestUI {
  8. public static class Pojo {
  9. private String string;
  10. public String getString() {
  11. return string;
  12. }
  13. public void setString(String string) {
  14. this.string = string;
  15. }
  16. }
  17. @Override
  18. protected void setup(VaadinRequest request) {
  19. TextField textField = new TextField("TextField with null value");
  20. textField.setInputPrompt("Me is input prompt");
  21. textField.setNullRepresentation(null);
  22. textField.setValue(null);
  23. addComponent(textField);
  24. TextField textField2 = new TextField(
  25. "TextField with null data source value");
  26. textField2.setInputPrompt("Me is input prompt");
  27. textField2.setNullRepresentation(null);
  28. BeanItem<Pojo> beanItem = new BeanItem<>(new Pojo());
  29. textField2.setPropertyDataSource(beanItem.getItemProperty("string"));
  30. addComponent(textField2);
  31. }
  32. @Override
  33. protected String getTestDescription() {
  34. return "Input prompt should be shown when data source provides null";
  35. }
  36. @Override
  37. protected Integer getTicketNumber() {
  38. return 11021;
  39. }
  40. }