Tooltip for table row

I noticed that the Vaadin 6.7.0beta1 supports to add tooltip for the row. Is there any example how to do this?


Row and cell tooltips are added using ItemDescriptionGenerators, here is a quick example:

table.setItemDescriptionGenerator(new ItemDescriptionGenerator() {                             
    public String generateDescription(Component source, Object itemId, Object propertyId) {
        if(propertyId == null){
            return "Row description "+ itemId;
        } else if(propertyId == COLUMN1_PROPERTY_ID) {
            return "Cell description " + itemId +","+propertyId;
        return null;

I did use this snippet of the code, but there is no tooltip when mouse over.


I just tested this with a simple table.
It seems that it only works for a string in the cell. Nothing would happen when I added a Label/Button in the cell.

Thats right, that will only work for text cells since components usually have their own tooltip functionality.

So, instead of adding the tooltips to the Table add them to the components you are adding to the table. Labels and Buttons have the setDescription() method for that purpose.

Hi John,

Thanks for your reply. However, there are text cells and some other components in my table, and there is no effect after I added the tooltips for the table. Cannot find the reason.


Doesn’t work for me as well.
The Table does set the “rowdescr” attribute to a valid value that was generated in my itemdescriptor class but no tooltip.
Anyone knows why?

hi guys

i have a table with data generated from database,i want to add tooltip ,for

tooltip will be
according to rows

What John Ahlroos posted in this thread still applies to the current Vaadin versions.
If you have just text (so no ColumnGenerators) you just use the ItemDescriptionGenerator (There should be a bit more information on it in the Book of Vaadin or just generally on the web, just google “Vaadin ItemDescriptionGenerator”)
If you have columns with components inside them like labels, buttons etc. you have to add the tooltips right to the components (again just google “vaadin component tooltip” or something like this and there should be plenty information out there).

I didn’t expect the generateDescription method to be called as items are added to the container. I had assumed/hoped the generator would be called on-the-fly when the mouse hovered over a cell.

With generateDescription method being called for every cell as my datasource is populated, it creates an unusable performance problem for me. I have a big table full of data, that only a portion of is visible at any one time, there is no need to generate descriptions for cells that aren’t even in view.

Am I missing something, perhaps using this wrong? Does anyone know how to only incur the description generation cost when the user is actually hovering over a cell (asking for it)?

I agree with Gregg.
The generateDecription method should be called on mouse over and not when the component is attached.