Paul Schifferer
Paul Schifferer

Reputation: 509

How do I store arbitrary data in a GWT widget?

I'm creating a table using GWT, and in certain cells of the table, I want to store a piece of data in that cell's Widget for use in the Widget's handler callback. I can't seem to find an API method such as widget.setData(key, value);. How do I (or can I) accomplish this?

Upvotes: 0

Views: 353

Answers (1)

AlexJReid
AlexJReid

Reputation: 1601

You could subclass the widget you want - and add the appropriate members and get/set methods.

The table example may be better served by storing the object inside a button instance, i.e an 'Edit' button.

Alternatively, you could maintain a map of objects that relate to each row index. This would save creating a lot of unnecessary widgets.

Upvotes: 1

Related Questions