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.

FormWithNestedProperties.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package com.vaadin.tests.fieldgroup;
  2. import com.vaadin.annotations.PropertyId;
  3. import com.vaadin.tests.data.bean.Address;
  4. import com.vaadin.tests.data.bean.Country;
  5. import com.vaadin.tests.data.bean.Person;
  6. import com.vaadin.tests.data.bean.Sex;
  7. import com.vaadin.tests.util.Log;
  8. import com.vaadin.ui.CheckBox;
  9. import com.vaadin.v7.data.fieldgroup.BeanFieldGroup;
  10. import com.vaadin.v7.ui.NativeSelect;
  11. import com.vaadin.v7.ui.TextField;
  12. public class FormWithNestedProperties extends AbstractBeanFieldGroupTest {
  13. private Log log = new Log(5);
  14. private TextField firstName = new TextField("First name");
  15. private TextField lastName = new TextField("Last name");
  16. private TextField email = new TextField("Email");
  17. private TextField age = new TextField("Age");
  18. @PropertyId("address.streetAddress")
  19. private TextField streetAddress = new TextField("Street address");
  20. private NativeSelect country;
  21. private CheckBox deceased = new CheckBox("Deceased");
  22. @Override
  23. protected void setup() {
  24. super.setup();
  25. setFieldBinder(new BeanFieldGroup<>(Person.class));
  26. country = (NativeSelect) getFieldBinder().buildAndBind("country",
  27. "address.country", NativeSelect.class);
  28. getFieldBinder().bindMemberFields(this);
  29. addComponent(firstName);
  30. addComponent(lastName);
  31. addComponent(streetAddress);
  32. addComponent(country);
  33. addComponent(email);
  34. addComponent(age);
  35. addComponent(deceased);
  36. addComponent(getCommitButton());
  37. addComponent(getDiscardButton());
  38. addComponent(getShowBeanButton());
  39. getFieldBinder().setItemDataSource(new Person("First", "Last", "Email",
  40. 52, Sex.FEMALE,
  41. new Address("street address", 01234, "City", Country.FINLAND)));
  42. }
  43. @Override
  44. protected String getDescription() {
  45. // TODO Auto-generated method stub
  46. return null;
  47. }
  48. @Override
  49. protected Integer getTicketNumber() {
  50. // TODO Auto-generated method stub
  51. return null;
  52. }
  53. }