GWT Custom Cell in CellList - render() not being called

299 Views Asked by At

I'm having trouble figuring out why my render method isn't being called. Here is my custom cell that extends AbstractCell, broken down to its simplest form.

public class FormHistoryCell<T> extends AbstractCell<T> {

@Override
public void render(com.google.gwt.cell.client.Cell.Context context, T value, SafeHtmlBuilder sb) {

    System.out.println("Rendering customer cell...");

    if (value == null) {
        return;
    }
}

}

Here is the snipet in my code which creates an instance of "FormHistoryCell" and attempts to add it to a CellList.

@UiFactory
CellList<FormHistoryCell> initList() {
    FormHistoryCell formHistoryCell = new FormHistoryCell();
    CellList historyList = new CellList<FormHistoryCell>(formHistoryCell);

    return historyList;
}

I have tried different things like adding a constructor that takes a String argument, etc. The constructor is called, but the render method is not. Looking at that Abstract class it extends, it seems the render method is called within the "setValue" method, but didn't see where that is called in other custom cell extensions whose render methods seem to be getting called just fine. I'm sure I'm missing something obvious here but can't figure out what. Please help.

1

There are 1 best solutions below

0
On

Based on the code you provided, there is no reason for a browser to call the render method of your cell. You simply passed a reference to an object FormHistoryCell to your CellList. The render method is only needed when a browser has to display a cell and its content. This happens when you add data to your CellList, as @outellou suggested.