Problems with Table Item insert

I have the following table consisting of a Datefield, String and a checkbox -

Table etable = new Table();
etable.addContainerProperty("expires", DateField.class,null);
etable.addContainerProperty("version", String.class, null);
etable.addContainerProperty("select", CheckBox.class, null);

I can add a single row using the following:

DateField d = new DateField();
Object[] obj = {d,new String(), new CheckBox()};

The above code is part of a method which I call every time I want to generate a new row in the table, which makes adding a new empty row easier. However, it works only in theory and not in practice. I have a shortcut listener which adds a new row everytime a key is pressed and the above method is called to do the job. Unfortunately, it works just once and all subsequent calls result in empty rows being generated.

I read somewhere in the forums, that it is possible to insert an instance of a component just once in the table. Does this have something to do with the problem I’m facing? This is pretty strange as I create a new instance everytime my method is called.

You are calling the wrong method. You should be calling

etable.addItem(obj, rowId);

If you don’t care about what the rowId is, you could create a Long object whose value increment for each row.
or even use the overloaded addItem( ) function also.

Thank you. That really helped sort out the confusion :slight_smile: