Ashish
Ashish

Reputation: 14707

How to return List of Object from server in GWT

I am using the tutorial explaining the usage of asyncdataprovider to create the celltable http://www.mytechtip.com/2010/11/gwt-celltable-example-using_8168.html. Tutorial mentioned that you can return the list of object from the server.

   // Associate an async data provider to the table
    AsyncDataProvider<Contact> provider = new AsyncDataProvider<Contact>() {
      @Override
      protected void onRangeChanged(HasData<Contact> display) {
        final int start = display.getVisibleRange().getStart();
        int length = display.getVisibleRange().getLength();
        AsyncCallback<List<Contact>> callback = new AsyncCallback<List<Contact>>() {
          @Override
          public void onFailure(Throwable caught) {
            Window.alert(caught.getMessage());
          }
          @Override
          public void onSuccess(List<Contact> result) {
            updateRowData(start, result);
          }
        };
        // The remote service that should be implemented
        remoteService.fetchPage(start, length, callback);
      }
    };

Could someone please tell me how can I return a list of object from the server.

Upvotes: 1

Views: 732

Answers (2)

Arash Moradabadi
Arash Moradabadi

Reputation: 1

Please don't forget you only can pass serializable objects through RPC. So you can't use List types or you should serialize it.

Upvotes: 0

Christian Kuetbach
Christian Kuetbach

Reputation: 16060

I thinkt this tutorial will help you:

http://www.tutorialspoint.com/gwt/gwt_rpc_communication.htm

Another good place to look for information is:

http://www.gwtproject.org/doc/latest/tutorial/RPC.html

Upvotes: 2

Related Questions