Thursday, August 29, 2013

Re: CellTable of Strings

Thanks guys. For now I ended up creating an object with different column attributes just like what Rogelio was saying. It's not the cleanest code but I think it works. I don't have any deadline on this so I will go ahead and give Thomas' suggestion a try. I have not played with Guava at all but I'm excited to learn that also.

Thanks again for your responses.


On Tuesday, August 27, 2013 5:41:26 AM UTC-4, Thomas Broyer wrote:
No need to create an object, you can use a List<String> to represent a row, and you'd then feed the table with List<List<String>>, which can be easily created from a List<String> using Guava for instance:, int)

But CellTable might not be the appropriate widget if all you want to do is display a list, partitioned with 4 items per line. You can achieve similar layouts using a CellList and appropriate styling (just beware when upgrading GWT that the structure hasn't changed from the previous version, as it's an "implementation detail" and not guaranteed to stay the same), or create your own widget.
CellTable is best when you have a concept of "rows" that can be selected on their own.

On Monday, August 26, 2013 6:39:15 PM UTC+2, Rogelio Flores wrote:
Yes, create an object that will have column1, etc as attributes, then create a List<Word> and populate it with your source list however you want to (preferably you might want to send this list like your CellTable will use already populated from the server):

public class Word {
   String column1;
   String column2;
   String column3;
   String column4;
   // add setters and getters

List<Word> wordList = new ArrayList<Word>(); // or whatever List implementation you like/need

// populate wordList as needed from your source list(s) and add it to your ListDataProvider.

// Create column1
TextColumn<Word> columnOne = new TextColumn<Word>() {
@Override public String getValue(Word word) { return word.getColumn1;
} };

On Friday, August 23, 2013 2:24:58 PM UTC-4, Noel Reforma wrote:
Hello. I'm trying to build a table (20 rows x 4 columns) of just Strings. I'm using a CellTable and use the ListDataProvider but since my datasource is just a List<String>, I'm having trouble trying to figure out how to split my list so that it will put 20 per column. Initially, I'm thinking about just creating an object that will have column1, column2, column3 and column4 as attributes but I'm not sure if this is the best way to do it.

public Word {

  List<String> column1;
  List<String> column2;
  List<String> column3;
  List<String> column4;

I guess this is more of a design question. i'm just looking for a cleaner way of doing it. Since I can't do the following because I just have a List<String>, I how can I distinguish the set that will go to col1 and col2...etc.
    // Create address column.      TextColumn<Contact> addressColumn = new TextColumn<Contact>() {          @Override          public String getValue(Contact contact) {              return contact.address; // I cannot do something like this...should I use an Array so I can point to the next column?          }      };

Thanks. Any advice is appreciated.


You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment