2016-10-27 70 views
0

我有以下的ButtonCell。如何使其響應點擊(例如,addClickHandler)?我嘗試了很多我找不到的方法。沒有一個Window.alert返回響應。GWT Java - CellTable - ButtonCell - 如何讓它響應點擊

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

回答

2

你只需要在update列設置一個FieldUpdater

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