I have a verticalPanel with a table in it. OnModuleLoad I get data from database which I display in a table. On button click I want to add new data from a listbox to it. It works fine but I dont know how to update the table/panel. What I do at the momemt is to create a new Table to show the data but I cant delete the first table. Do I have to attach the table to the panel to be able to delete it? Actually I dont like this solution thats why I was wondering if theres an update method or something.
Create Table
public void createTimeTable(){
//Table and Panel -> created globally
//On Load -> get all times which are already booked
serviceImplURL.getRpcDB().getBookedTimes(username, new AsyncCallback<ArrayList<Times>>() {
/**
*/
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
/**
*/
@Override
public void onSuccess(ArrayList<Times> startList) {
/**
*/
table.setRowCount(startList.size(), true);
table.setRowData(0, startList);
// Add column to show the start time.
TextColumn<Times> startColumn
= new TextColumn<Times>() {
@Override
public String getValue(Times times) {
return Double.toString(times.getStart());
}
};
table.addColumn(startColumn, "Beginn");
// Add column to show the pause time.
TextColumn<Times> pauseColumn
= new TextColumn<Times>() {
@Override
public String getValue(Times times) {
return Integer.toString(times.getPause());
}
};
table.addColumn(pauseColumn, "Pause in Minuten");
// Add column to show the end time.
TextColumn<Times> endColumn
= new TextColumn<Times>() {
@Override
public String getValue(Times times) {
return Double.toString(times.getEnd());
}
};
table.addColumn(endColumn, "Ende");
//table panel
panel.setBorderWidth(1);
panel.setWidth("400");
panel.add(table);
panel.getElement().setId("mainTable");
// Add the widgets to the root panel.
RootPanel.get().add(panel);
}
});