Search code examples
javagwtuibinder

How to update a cell value by code?


I have a CellWidget (EditTextCell) that I want to set a specific value manually by code. But the UI is not updated when I use the following code? What am I missing?

@UiField(provided = true)
CellWidget<String> cell;

cell.setValue(text, true);
cell.redraw();

Solution

  • To answer my own question, as I found a workaround:

        ((EditTextCell) cell.getCell()).clearViewData(KEY_PROVIDER.getKey(text));
        cell.getCell().setValue(new Context(0, 0, KEY_PROVIDER.getKey(text)), cell.getElement(), text);
        cell.setValue(text, true, true);
    

    Don't know if this is the proper way to force an update on a single cellwidget textcell, but at least it works.