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 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2012 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.components.textfield;
  17. import com.vaadin.data.util.BeanItem;
  18. import com.vaadin.server.VaadinRequest;
  19. import com.vaadin.tests.components.AbstractTestUI;
  20. import com.vaadin.ui.TextField;
  21. public class TextFieldWithDataSourceAndInputPrompt extends AbstractTestUI {
  22. public static class Pojo {
  23. private String string;
  24. public String getString() {
  25. return string;
  26. }
  27. public void setString(String string) {
  28. this.string = string;
  29. }
  30. }
  31. @Override
  32. protected void setup(VaadinRequest request) {
  33. TextField textField = new TextField("TextField with null value");
  34. textField.setInputPrompt("Me is input prompt");
  35. textField.setNullRepresentation(null);
  36. textField.setValue(null);
  37. addComponent(textField);
  38. TextField textField2 = new TextField(
  39. "TextField with null data source value");
  40. textField2.setInputPrompt("Me is input prompt");
  41. textField2.setNullRepresentation(null);
  42. BeanItem<Pojo> beanItem = new BeanItem<Pojo>(new Pojo());
  43. textField2.setPropertyDataSource(beanItem.getItemProperty("string"));
  44. addComponent(textField2);
  45. }
  46. @Override
  47. protected String getTestDescription() {
  48. return "Input prompt should be shown when data source provides null";
  49. }
  50. @Override
  51. protected Integer getTicketNumber() {
  52. return 11021;
  53. }
  54. }