1

Simple question: I have a CellTable filled with Keyword objects. Now, I would like to retrieve all the Keywords in that CellTable. Is this possible? If not, why? Surely there must be a way...

I can not understand how this is so hard (well maybe it isn't but I just can't seem find the answer for the life of me).

Some code to clarify:

//my celltable
private CellTable<Keyword> ctKeywordsLinked = new CellTable<Keyword>();

//listdataprovider to fill my celltable with
private ListDataProvider<Keyword> dataProviderLinkedKeywords = new ListDataProvider<Keyword>();

//add 4 keyword objects to the listdataprovider to fill the celltable
dataProviderLinkedKeywords.getList().add(new Keyword);
dataProviderLinkedKeywords.getList().add(new Keyword);
dataProviderLinkedKeywords.getList().add(new Keyword);
dataProviderLinkedKeywords.getList().add(new Keyword);

So now that I have my celltable filled, I would like to retrieve those 4 keywords without touching the listdataprovider. I hope everything is a bit more cleared up :-)

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Jack
  • 87
  • 2
  • 13
  • you want to get the update record from celltable? – moh May 29 '15 at 09:53
  • Not quite sure what you mean by update record, but I have a Celltable with let's say 4 rows (which basically are 4 Keyword objects I added). Now I want to retrieve those 4 objects from the Celltable. I'll add some code to the original question to clearify things. – Jack May 29 '15 at 09:58
  • Why you need to get rows via CellTable? You can always get provider from it. – cybersoft May 29 '15 at 10:52
  • @cybersoft is it possible to get the listdataprovider from the celltable? Because I cannot find any methods that would do that. I'd expect something like this; ctKeywordsLinked.getListDataProvider() or something, but that obviously doesn't work. Or are you referring to the dataProviderLinkedKeywords object itself? That is how I am doing it at the moment, but I don't really like it. – Jack May 29 '15 at 11:30
  • 1
    Sure, it is CellTable#getKeyProvider (ListDataProvider implements interface ProvidesKey), but you have to cast it to ListDataProvider. I'd just place this provider to the class field and use it later – cybersoft May 29 '15 at 13:00
  • 1
    Using the `ListDataProvider` is the intended way to get/set the data of a `CellTable`. It's its purpose, i.e. it hasn't been called 'data provider' just randomly. – francesco foresti May 29 '15 at 13:33
  • Ok guys, thanks alot for the answers! @cybersoft; if you could turn that comment into an answer i'd gladly accept it as such :) – Jack May 29 '15 at 17:08
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). BTW, it's "Thanks in advance", not "Thanks in advanced". – John Saunders Jun 06 '15 at 23:37
  • No, YOU don't use "thanks", I do ;-) – Jack Jun 08 '15 at 07:03

1 Answers1

3

CellTable has method getKeyProvider, which returns object containing data under ProvidesKey interface.

You create ListDataProvider and pass it to cell table, so you can get that provider from cell table again at any time:

ListDataProvider provider = (ListDataProvider)cellTable.getKeyProvider();
provider.getList().get(0); // get first Keyword
cybersoft
  • 1,453
  • 13
  • 31