Insert Data to Table

how to insert data into two different tables , please help me : )

The same way you insert data to the single table. Just provide datasource instance to one or to several table. For instance:


BeanItemContainer myds = new BeanItemContainer..... // initialize and populate with data

table1.setContainerDatasource( myds );
table2.setContainerDatasource( myds );

thanks for your answer, sorry but my intention is to insert into two different class / object

table1 and table2 are different objects (instances of a table). Or you’re meaning something else I didn’t catch ? Would you please explain your requirements in more details?

i understood you have one table and you want to insert two differrent type object. You can use IndexedContainer For example ;
You have two objects which names Car and Phone ;
class Car {
String name;
String model;
}
class Phone {
String name;
String emei;
}

Table table = new Table(“Two different object diplay table”);
IndexedContainer ic = new IndexedContainer();
ic.addContainerProperty(“NAME”, String.class, “”);
ic.addContainerProperty(“MODEL”, String.class, “”);
ic.addContainerProperty(“EMEI”, String.class, “”);

You are ready now add new Car;

Object id = ic.addItem();
ic.getContainerProperty(id, “NAME”).setValue(car.getName());
ic.getContainerProperty(id, “MODEL”).setValue(car.getModel());

You are ready now add new Phone;

Object id = ic.addItem();
ic.getContainerProperty(id, “NAME”).setValue(phone.getName());
ic.getContainerProperty(id, “EMEI”).setValue(phone.getEmei());

and set table container table.setContainerDataSource(ic);

it will dispaly two different object.