javagwtcelltable

GWT Java - CellTable - ButtonCell - how to make it respond to a click


I have the following ButtonCell. How do I make it respond to a click please (e.g., addClickHandler)? I have tried a number of ways I have found yet none work. None of the Window.alert return a response.

        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");

Solution

  • You just need to set a FieldUpdater on the update column:

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