I have a CellTable in GWT, where the last column is a ButtonCell. I wanted to add tooltips to the buttons, based on an attribute of the object used. The problem is that each object has different values for that attribute, but GWT displays the same tooltip text for all the buttons(taken from the last row of the table). Any tips?
final ButtonCellDefinitionExtended<MyObject> def = new ButtonCellDefinitionExtended<MyObject>() {
@Override
public boolean isVisible(MyObject bean) {
return bean.getAttribute1() != null;
}
@Override
public String getTooltip(MyObject bean) {
return bean.getAttribute2(); //doesn't work
}
};
The class:
public class ButtonCellDefinitionExtended<T> extends CellColumnDefinition<T, String> {
private String tooltipText;
private TooltipCellDecorator<String> cellDecorator;
private ButtonCell buttonCell;
public ButtonCellDefinitionExtended() {
buttonCell = new ButtonCell();
cellDecorator = new TooltipCellDecorator<>(buttonCell);
}
@Override
protected Cell<String> getCell() {
return cellDecorator;
}
@Override
protected String getValueOf(T bean) {
//Button
buttonCell.setEnabled(isEnabled(bean));
buttonCell.setVisible(isVisible(bean));
//Tooltip
if (getTooltip(bean) != null) {
cellDecorator.setText(getTooltip(bean));
}
cellDecorator.setPlacement(Placement.LEFT);
return getButtonText(bean);
}
P.S: The visibility of the buttons is correctly set for each of them.