Vaadin Combobox数据绑定

时间:2015-02-22 16:28:23

标签: java vaadin

我在datasource中包含来自combobox的数据时遇到问题。 我的第一个Combobox就是这样填充的 -

public class Person implements Serializable {

    public String firstName;
    public String lastName;


    public Person (final String firstName, final String lastName) {
        this.firstName= firstName;
        this.lastName = lastname;
    }

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setFirstName(final String firstName) {
        this.firstName = firstName;
    }

    public void setLastName(final String lastName) {
        this.lastName = lastname;
    }
}

现在我创建一个BeanContainer并填写它 -

  Combobox Name = new Combobox("Person");

  final BeanItemContainer<Person> personContainer = new BeanItemContainer<Person>(Person.class);

  this.personContainer.setBeanIdProperty("firstName");

  BeamItem person1 = personContainer.addBean(new Person("Tom", "Bauer"));
  BeanItem person2 = personContainer.addBean(new Person("Laura", "Simpsons"));
  BeanItem person3 = personContainer.addBean(new Person("John", "Doe"));

  this.Name.setContainerDataSource(personContainer);
  this.Name.setRequired(true);
  this.Name.setImmediate(true);
  this.Name.setNullSelectionAllowed(false);

结果是填充Combobox。到现在为止还挺好。但现在我想创建第二个Combobox,它取决于Person Combobox。所以我们打电话给第二个Combobox语音。当我在第一个Combobox中选择一个项目时,我希望手机组合框中的项目将根据用户选择的名称更改其值。我将从后端获得的Phonenumbers类似于第一个Combobox的名称。

0 个答案:

没有答案