【问题标题】:GWT Custom Cell in CellList - render() not being calledCellList 中的 GWT 自定义单元格 - 未调用 render()
【发布时间】:2014-12-29 22:47:12
【问题描述】:

我无法弄清楚为什么我的渲染方法没有被调用。这是我的自定义单元格,它扩展了 AbstractCell,分解为最简单的形式。

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;
    }
}

}

这是我的代码中的片段,它创建“FormHistoryCell”的一个实例并尝试将其添加到 CellList。

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

    return historyList;
}

我尝试了不同的方法,比如添加一个带有字符串参数的构造函数等。构造函数被调用,但渲染方法没有被调用。查看它扩展的抽象类,似乎在“setValue”方法中调用了渲染方法,但没有看到在其他自定义单元扩展中调用该方法的位置,其渲染方法似乎被调用得很好。我确定我在这里遗漏了一些明显的东西,但不知道是什么。请帮忙。

【问题讨论】:

  • 我认为您需要在 CellList 中设置一些数据才能调用渲染

标签: java gwt uibinder celllist


【解决方案1】:

根据您提供的代码,浏览器没有理由调用您单元格的render 方法。您只需将对象 FormHistoryCell 的引用传递给您的 CellList。 render 方法仅在浏览器必须显示单元格及其内容时才需要。正如@outellou 建议的那样,当您将数据添加到 CellList 时会发生这种情况。

【讨论】:

    猜你喜欢
    • 2013-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多