GWT celltable自定义列setfieldupdater不适用于ListBox

GWT celltable自定义列setfieldupdater不适用于ListBox,gwt,celltable,Gwt,Celltable,我创建了一个自定义单元格,用于确定是显示SelectionCell还是TextCell。对于SelectionCell渲染,我无法启动setFieldUpdater方法 下面的代码 private class CustomTypeCell extends AbstractCell<String> { SelectionCell selectCell = new SelectionCell(cardMnemonics); TextCell textCell = new

我创建了一个自定义单元格,用于确定是显示
SelectionCell
还是
TextCell
。对于
SelectionCell
渲染,我无法启动
setFieldUpdater
方法

下面的代码

private class CustomTypeCell extends AbstractCell<String>
{
    SelectionCell selectCell = new SelectionCell(cardMnemonics);
    TextCell textCell = new TextCell();

    @Override
    public void render(
            Context context,
            String value, SafeHtmlBuilder sb)
    {
        if (value != null)
        {
            textCell.render(context, value, sb);
        }
        else
        {
            selectCell.render(context, "", sb);
        }

    }
}


    private class CustomTypeColumn extends Column<Object, String>
{

    public CustomTypeColumn(CustomTypeCell cell)
    {
        super(cell);
    }

    @Override
    public String getValue(Object object)
    {
        return object.getStringValue();
    }
}
私有类CustomTypeCell扩展了AbstractCell
{
SelectionCell selectCell=新的SelectionCell(卡片助记符);
TextCell TextCell=新的TextCell();
@凌驾
公共无效渲染(
语境,
字符串值,安全HtmlBuilder sb)
{
if(值!=null)
{
render(上下文、值、sb);
}
其他的
{
选择cell.render(上下文“,”sb);
}
}
}
私有类CustomTypeColumn扩展了列
{
公共CustomTypeColumn(CustomTypeCell单元格)
{
超级电池;
}
@凌驾
公共字符串getValue(对象)
{
返回object.getStringValue();
}
}
使用

CustomTypeCell cell = new CustomTypeCell();
CustomTypeColumn customCol = new CustomTypeColumn(cell);

customCol.setFieldUpdater(new FieldUpdater<Object, String>()
    {
        public void update(int index, Object object, String value)
        {
            object.setStringValue(value);
            // perform action           }
    });
cellTable.addColumn(customCol, "Custom Column");
CustomTypeCell单元格=新的CustomTypeCell();
CustomTypeColumn customCol=新的CustomTypeColumn(单元格);
customCol.setFieldUpdater(新的FieldUpdater()
{
公共void更新(int索引、对象、字符串值)
{
object.setStringValue(值);
//执行操作}
});
cellTable.addColumn(customCol,“自定义列”);

如果我使用带有
SelectionCell
的标准列进行渲染,这就可以了。渲染还不够,您还需要将事件处理委托给相应的单元格实现:将if/else构造添加到
onBrowserEvent
中,并确保在
getConsumedEvents
中侦听相应的事件
您可能还应该实现
resetFocus


您可能会从代码中找到灵感。

谢谢,在添加getConsumedEvents和onBrowserEvent后,更改SelectionCell值后将调用setFieldUpdater方法。