GWT Java - CellTable - ButtonCell - 如何使其响应点击

时间:2016-10-27 21:40:29

标签: java gwt celltable

我有以下ButtonCell。如何让它响应点击(例如addClickHandler)?我尝试了很多方法,但我找不到任何方法。没有Window.alert返回响应。

        ButtonCell selectButton = new ButtonCell();
        Column <HikingMeals,String> update = new Column <HikingMeals,String>(selectButton){
            @Override
            public String getValue(HikingMeals selectButton) 
            {
                return "Select";
            }
            public void execute(HikingMeals selectButton) {
                // EDIT CODE
                Window.alert("Pressed");
             }
            //@Override
            public void update(int index, HikingMeals object, String value) {
                // The user clicked on the button for the passed auction.
                Window.alert("Pressed2");
            }
        };
        table.addColumn(update, "Select");

1 个答案:

答案 0 :(得分:2)

您只需在FieldUpdater列上设置update

update.setFieldUpdater(new FieldUpdater<HikingMeals, String>() {
    @Override
    public void update(int index, HikingMeals object, String value) {
        Window.alert("Pressed");
    }
});