Vaadin - How to bind a List of POJO

In Vaadin 7, I'm trying to bind my ComboBox of phone numbers to a list of POJO nested in a POJO. For exemple: I have PersonVo that contains a List phones; and PersonCommunicationVo contains the value of the phone number.

What I used for binding the others properties of PersonVo is:

BeanFieldGroup<PersonVo>personBinder = new BeanFieldGroup<PersonVo>(PersonVo.class);
myFormLayout.addComponent(personBinder.buildAndBind("Firstname", "firstName"));
myFormLayout.addComponent(personBinder.buildAndBind("Country", ""));

Here PersonVo:

@Table(name = "CONTACT.T_PERSON")
public class PersonVo {

    @Column(name="id",updatable = false)
    private Long personId;

    @Column(name = "FIRSTNAME")
    private String firstName;

    @Column(name = "LASTNAME")
    private String lastName;

    @Column(name = "TITLE")
    private String title;


    @OneToMany(fetch = FetchType.LAZY, mappedBy = "personId")
    @AuditMappedBy(mappedBy = "personId")
    private List<PersonCommunicationVo> **phoneNumbers**;


and PersonCommunicationVo:


public class PersonCommunicationVo {
    @Column(name="id",updatable = false)
    private Long persCommId;

    @Column(name = "PERSON_ID")
    private Long personId;

    @JoinColumn(name = "COM_TYPE_ID")
    private CommunicationTypesVo communicationType;

    @Column(name = "VALUE")
    private String **value**;

And what I would like to do is to bind my combobox of phone number to the list phoneNumbers from PersonVo based on the value from PersonCommunicationVo. But the difficulty is to reach the right PersonCommunicationVo in the list base on what has been selected in the combobox. For exemple: I have selected the phone number +32 123 456 789 in the combobox and this value should be map to the phoneNumbers.get(indexOfSelectedItem).getValue(). In order to update the phone number, add a new one etc...

Thanks for the help!


maybe i didnt understand your datamodel, if so, could you please post PersonVo, PhoneVo(?) and PersonCommunicationVo and explain it a little further why you want to save it like you do. why does your personvo contain a List of phones? i've never worked with a beanfieldgroup before, but i think of something like:

ComboBox cb = new ComboBox("Phones", person.getPhones())
personBinder.bind(cb, "phones");

You can try something like this (java 1.7 syntax and Vaadin7):

    FieldGroup fGroup = new FieldGroup( new BeanItem<PersonVo> (personInstance) );
    BeanItemContainer<PersonCommunicationVo> numbers = new BeanItemContainer<>( PersonCommunicationVo.class );
    numbers.addAll( personInstance.getPhoneNumbers() );

    ComboBox phoneCombo = new ComboBox( "Phone Numbers", numbers );
    phoneCombo.setItemCaptionMode( ItemCaptionMode.PROPERTY );
    phoneCombo.setItemCaptionPropertyId( "**value**" );

    fGroup.bind (phoneCombo, "**phoneNumbers**")


Need Your Help

c# wav to mp3, but error, the error is 0x8007000B

c# mp3 wav

I need to use c# convert wav to mp3.