I created a CellTable with contacts. Some of the contacts are already filled into the table by the client. In the onModuleLoad function an additional Contact object is requested. Now I'd like to add another row to the table
In the function onModuleLoad I added the table widget, in the onSuccess I would like to add a new data row to the table with the received contact:
List<Contact> cList = getKnownContacts();
CellTable<Contact> table = new CellTable<Contact>();
final ListDataProvider<Contact> dataProvider = new ListDataProvider<Contact>();
dataProvider.setList(cList);
dataProvider.addDataDisplay(table);
// Create name column.
TextColumn<Contact> nameColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact contact) {
return contact.getName();
}
};
// Create address column.
TextColumn<Contact> addressColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact contact) {
return contact.getAddress();
}
};
table.addColumn(nameColumn, "Name");
table.addColumn(nameColumn, "Address");
RootPanel.get().add(table);
contactService.getContactById(1234,
new AsyncCallback<Contact>() {
public void onFailure(Throwable caught) {
...
}
public void onSuccess(Contact result) {
// add row to table???
}
}
);