Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    GWT,RPC & Datasources

    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:
    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
    	    );
    	}
    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.
    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);
    }
    Any help would be much appreciated.

    #2
    You seach the forums for GwtRPCDataSource, it allows you to write your RPC as normal but it will act in the same fashion as a normal datasource. The code can be found in the smartgwt-extensions project.

    Comment


      #3
      Thanks, I will look more into GWTRPC.

      Comment

      Working...
      X