Question

I want to populate the celltable with the data that comes from database through RPC call. Can someone give me an example application which demonstrates this(end to end flow). im bit confused and i am new to this. Thanks for the help

Was it helpful?

Solution

I had the same problem getting started with a CellTable. In my case I had to fill the CellTable with different data types to represent data points with x- and y-coordinates.

My solution was to create an interface and give objects implementing this interface to the CellTable: The interface:

    public interface IsDataTablePresentable {
       public String xValue();
       public String yValue();
    }

and the instance of CellTable:

    final CellTable<IsDataTablePresentable> dataTable = new CellTable<IsDataTablePresentable>();

Then you create Columns depending on the type of data, in my case a TextColumn to represent the corresponding x-value as String:

    TextColumn<IsDataTablePresentable> xValueColumn = new TextColumn<IsDataTablePresentable>() {
        @Override
        public String getValue(IsDataTablePresentable object) {
            return object.xValue();
        }
    };
    dataTable.addColumn(xValueColumn, "the x-axis title");

The code for y-values looks the same, except that I take the y-value ;)

After that, add data to the CellTable:

    dataTable.setRowData(0, (ArrayList<IsDataTablePresentable>) <your field or RPC-returned ArrayList or whatever here!> );

That's it!

Edit: Example for a class implementing IsDataTablePresentable:

    public class timeData implements IsSerializable, IsDataTablePresentable {
    ...
       public String xValue() {
          return ""+this.time.getDate() + "." + (this.time.getMonth()+1) + "." + (this.time.getYear()+1900);
       }

       public String yValue() {
          return this.value.toString();
       }
    ...
    }

For communicating with a server I recommend reading this article in the DevGuide, it helped me, too: Communicate with a Server - Google Web Toolkit

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top