inserting components in a table.

So I have this table definition:

lamesa.addContainerProperty("User Type", Select.class, null);
lamesa.addContainerProperty("Name", Select.class, null);
lamesa.addContainerProperty("To", CheckBox.class, null);
lamesa.addContainerProperty("cc", CheckBox.class, null);
lamesa.addContainerProperty("Bcc", CheckBox.class, null);
lamesa.addContainerProperty("Delete", CheckBox.class, null);

Then I have this button event:

add.addListener(new ClickListener() {
            public void buttonClick(ClickEvent event) {
                lamesa.addItem(new Object[]{ "","","","","",""},new Integer(x++));

From the codes above you can see that every click the table will add components inside it and it works. My only problem is that the two Select components will get its item from a list, I tried replacing the first " " in the addItem with the Select component I made something like this:

Select sel = new Select();
List<String>myList = new ArrayList<String>();

//then I'll loop the list size so I can bind the list items to the select component

//then in the event i'll do something like this
lamesa.addItem(new Object[]{ sel,"","","","",""},new Integer(x++));

this works for the first row of items in the table. but then I add another row then this happened:

Any Idea on how I can fix this? All the user type columns should have the same Select components and Items.


I think your problem is that you’re using the same instance of Select on every added row. Since one component instance can only be in one place at a time, it will be shown in the last added row. Try creating a new Select for each added row.

Thanks for that. Solved the problem. New problem, I’m trying to save all the data from all the select I’ve generated from clicking the button.

I bet there are better ways to do this, but you could for example loop through the item IDs in the container, fetch the relevant components (from properties of the item) for each row, fetch the value and save it.