Add empty row in my table

Hello guys i’m new on Vaadin and i’d like to set an empty row at first index of my table.

We need to have the possibility to fill that row for putting it in my table by an external button ‘Add’ from my layout.



Here is the code from my table :
(PS1: i’m using a BeanItemContainer )
(PS2: I underlined the importants elements of my table)

Thank you guys!

public class TableIndispo extends Table implements Ecouteur {

    private static final long serialVersionUID = 1L;
   
[b]
    private List<Room> roomTable;
    private BeanItemContainer<Room> containerz;
[/b]
   [b]
 private Long idBed;
[/b]
    private int count;
   
    public TableIndispo(final Long [b]
idBed
[/b]) {
        super();
        Emetteur.abonner(this);
        [b]
this.idBed = idBed;
[/b]
        count=0;
[b]
        roomTable = DAO.get().getAll(Room.class, "WHERE type != 'Open' and bed.id = "+idBed);
[/b]
[b]
        containerz = new BeanItemContainer<Room>(Room.class, roomTable);
[/b]
     
       [b]
 setContainerDataSource(containerz);
[/b]
       
           [b]
 //1st column : 'type'
[/b]
            addGeneratedColumn("type", new ColumnGenerator() {
                private static final long serialVersionUID = 1L;
                @Override
                public Object generateCell(Table source, Object itemId, Object columnId) {
                    count++;
                    [b]
ComboBox combo = new ComboBox();
[/b]
                    [b]
combo.addItems("Shutdown","Blocking","Decommissioning");
[/b]
                    combo.setNullSelectionAllowed(false);
                    combo.setImmediate(false);

                    [b]
Room r = containerz.getItem(itemId).getBean();
[/b]
                    System.out.println(dateBeginning+" ! "+dateEnd);
                    if([b]
r
[/b] instanceof Shutdown){
                        combo.select("Shutdown");
                        return combo;
                    }
                    else if([b]
r
[/b] instanceof Blocking){
                        combo.select("Blocking");
                        return combo;
                    }
                    else if([b]
r
[/b] instanceof Decommissioning){
                        combo.select("Decommissioning");
                        return combo;
                    }
                    else {
                        return null;
                    }
                }
            });
           
       [b]
 //2nd column : 'beginning' -> DateField
[/b]
        addGeneratedColumn("beginning", new ColumnGenerator() {
            private static final long serialVersionUID = 1L;
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                DateField df = new DateField();
                df.setDateFormat("dd-MM-yy hh:mm:ss");
                df.setValue((Date) source.getItem(itemId).getItemProperty(columnId).getValue());
                df.setImmediate(false);
                return df;
            }
        });
       
       [b]
 //3rd column : 'end' -> DateField
[/b]
        addGeneratedColumn("end", new ColumnGenerator() {
            private static final long serialVersionUID = 1L;
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                DateField df = new DateField();
                df.setDateFormat("dd-MM-yy hh:mm:ss");
                df.setValue((Date) source.getItem(itemId).getItemProperty(columnId).getValue());
                df.setImmediate(false);
                    return df;
            }
        });
       
      [b]
 //4st column : " "  -> button delete to delete the current row
[/b]
        addGeneratedColumn(" ", new ColumnGenerator() {
            private static final long serialVersionUID = 1L;
            @Override
            public Object generateCell(final Table source, final Object itemId, final Object columnId) {
           
                final Button b = new Button();   
                b.setIcon(new ThemeResource("delete.png"));       
                b.setSizeFull();
               
                b.addClickListener(new ClickListener(){
                    private static final long serialVersionUID = 1L;
                    @Override
                    public void buttonClick(ClickEvent event) {           
                        b.setStyleName("focus");
                                
                        //Prepare request for update the table dynamically for other users
                       [b]
 Request req = new Demande(ACTION.DELETE);
[/b]
                        req.params.put(PARAM.NAMECLASS, TableIndispo.class);
                        req.params.put(PARAM.ROOM, containerz.getItem(itemId).getBean());
                        req.params.put(PARAM.LIT, idBed);
                       
                        //delete the bean from the table
                       [b]
 DAO.get().delete(containerz.getItem(itemId).getBean()); 
[/b]
                       
                       //send the request
                    [b]
    Transmitter.send(req); 
[/b]
                    }               
                });               
               
                b.setImmediate(true);
                b.setSizeFull();

                return b;
            }
        });

[b]
        setVisibleColumns(new Object{"type", "beginning", "end", " "});
        setColumnHeaders(new String{"type", "beginning", "end", " "});   

        setColumnHeaderMode(ColumnHeaderMode.EXPLICIT);
[/b]
        setReadOnly(true);
        setSortEnabled(true);
        setColumnCollapsingAllowed(false);

    }

    public BeanItemContainer<Room> getContainerz() {
        return containerz;
    }
    public void setContainerz(BeanItemContainer<Room> containerz) {
        this.containerz = containerz;
    }

    @Override
    public void traiter(final Request req) {
       
        final UI ui = this.getUI();
        if(ui != null){
            ui.access(new Runnable() {
                @Override
                public void run() {                 
                        if(req.action == ACTION.ADD){
                          //do something
                        }
                        else if(req.action == ACTION.UPDATE){   
                          //do something
                        }


                      [b]
  else if(req.action == ACTION.DELETE){
                           
[/b]//delete the row from the table dynamically for every users
[b]
                           containerz.removeItem(req.params.get(PARAM.ROOM));
                        }   
[/b]                                    
                }
            }
            );
        }  
    }
   
    @Override
    public void detach() {
        Emetteur.desabonner(this);
        super.detach();
    }

}

Not sure if this helps, but BeanItemContainer’s got a method called
addItemAt(int index, Object newItemId)
.