3

i have a CellTable in my GWT Projekt with a CheckBox in each row. Somehow i need to iterate over all rows in the cellTable and need to check if the CheckBox of each row is selected or not.

I dont know how to do that and i cant find anything that shows how.

private Column<Article, Boolean> showPinColumn = new Column<Article, Boolean>(new CheckboxCell()) {
    public Boolean getValue(Article object) {
        return false;
    }
};
Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
user1882812
  • 936
  • 5
  • 18
  • 41
  • possible duplicate of [GWT:how to get the value of a checkbox of a cellTable](http://stackoverflow.com/questions/12476521/gwthow-to-get-the-value-of-a-checkbox-of-a-celltable) – Thomas Broyer Jan 09 '13 at 15:09

1 Answers1

5

Step 1 - You should fix your showPinColumn code and use FieldUpdater to actually update the object.

final CheckboxCell cbCell = new CheckboxCell();
Column<Article, Boolean> cbColumn = new Column<Article, Boolean>(cbCell) {
    @Override
    public Boolean getValue(Article object) {
        System.out.println("method getValue() - " + object.id + " - " + object.checked);
        return object.checked;
    }
};

cbColumn.setFieldUpdater(new FieldUpdater<Fieldupdater.Article, Boolean>() {
    @Override
    public void update(int index, Article object, Boolean value) {
        System.out.println("method update() - " + object.id + " - " + value);
    }
});

Step 2- You should only iterate over each of the items in the "list" that you set into the celltable and check for the boolean property in Article.

appbootup
  • 9,537
  • 3
  • 33
  • 65