ravi
ravi

Reputation: 1827

GWT ClickableTextCell

I am a newbie to GWT ... need some help in understanding the below class -

What is the use of GWT ClickableTextCell ??

Is there something specific use of it. It uses something called FieldUpdater, why is that used ?

Upvotes: 1

Views: 3891

Answers (2)

Steve J
Steve J

Reputation: 2674

Think of a ClickableTextCell as hot spot. It looks like a regular bit of screen real estate with text in it, but it responds to clicks. What happens when you click it? The click "updates" the field. An update to a field calls the method update(). What does update() do? Whatever you want it to. You provide it by specifying the FieldUpdater. FieldUpdater is an interface, so you can construct one anonymously. Say you have a CellTable, and you have a Column that displays a String inside a ClickableTextCell. You provide your FieldUpdater to the Column:

Column<DataType, String> myIntegerColumn 
      = new Column<DataType, String>(new ClickableTextCell());
myIntegerColumn.setFieldUpdater(new FieldUpdater<DataType, String>(){
  @Override
  public void update(int index, DataType object, String value){
    // execute code that reacts to a click on this hot spot
  }
});

Now whenever the cell gets clicked, that code in update() fires.

Upvotes: 11

ben_w
ben_w

Reputation: 736

A ClickableTextCell is a specific kind of cell. You can see a demo of all the different kinds of cells in this GWT showcase.

This GWT documentation explains what cell widgets are for, goes over all of the different types, and also has examples of how to use them and the ValueUpdater type.

Upvotes: 2

Related Questions