Bind textfields to specific items in a collection

Hi,

I searched the forum but haven’t found an answer to my problem yet. I’m still new to Vaadin and haven’t absorbed all the concepts yet.

My problem is the following: I have a list of different email and phone number types (e.g. “Office”, “Home”, “Mobile” as phone types). Each type has a ID and a name/description.
The types are extendable in the application.
Basically I have in my database a Table PHONE_TYPE (id, name), a table PERSON(id, …) and a table PHONE_DETAILS(id, type_id, member_id, number).
My JPA Person class has a collection of
PhoneDetails
.

When I show the screen with the contact details, I want to show text fields for all possible phone types. This is quite easy by iterating over the list of phone_types and creating a text field for each entry:

for (PhoneType type : phoneTypeList) {
   TextField phone = new TextField(type.getName());
   phone.setWidth("100%");
   contactPhone.addComponent(phone);
}

But how do I bind these textfields to the PhoneDetails list of my Persons object? I can create an entry or each PhoneType in this list. Can this be done automatically or do I have to manually (via ValueChangeListener) update the list?

Cheers
Klaus