I am a new smartGWT user and confused about how to use GWT RPC to create a Data Source that I can later use the data in smart grids and forms. I have the following working method:
What is the best way to get the data from the returned List<Contact>
to a DataSource. Do I need to use the loop and create a separate records and then assign them to the DataSource? i.e.
Any help would be much appreciated.
Code:
public class ContactList { public ContactList() { contactService.listContacts(new AsyncCallback<List<Contact>>() { public void onFailure(Throwable caught) { System.out.println("Failure:" + caught); } public void onSuccess(List<Contact> result) { try { int row = 0; for (Contact contact : result) { System.out.println("Row" + row + " " + contact.getName() + " " + contact.getEmail() + contact.getPhone()); row++; } } catch (Exception e) { } } }// end of inner class ); }
to a DataSource. Do I need to use the loop and create a separate records and then assign them to the DataSource? i.e.
Code:
for (Contact contact : result) { ListGridRecord record = new ListGridRecord(); record.setAttribute("name", contact.getName()); record.setAttribute("email",contact.getEmail()); record.setAttribute("phone", contact.getPhone()); ds.addData(record); }
Comment