java - CellList 中的 GWT 自定义单元 - 未调用 render()

标签 java gwt uibinder celllist

我无法弄清楚为什么我的渲染方法没有被调用。这是我的自定义单元格,它扩展了 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;
}

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

最佳答案

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

关于java - CellList 中的 GWT 自定义单元 - 未调用 render(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27697142/

相关文章:

java - 在 Hibernate 中映射具有递增列的复合键

java - 如何将一个文件合并到另一个\Linux

css - 如何在 GWT 中的另一个小部件(图像)之上显示一个小部件(Horizo​​ntalPanel)?

facebook - 你如何让 UiBinder 传递标签而不绑定(bind)它们以便 XFBML 工作?

java - 如何将 "á"等字符替换为相应的英文字母

java - Thread.start() 在控制台上打印 0

java - setContentsURL 相关问题

java - GWT 服务异常日志记录的最佳实践

java - 使用 SafeHtml 进行 anchor

css - 如何在 ui Binder 中将 css 设置为元素?