1
votes

Im using vaadin's TreeTable and im trying to add tooltips for my rows. This is how they say it should be done but the propertyId is always null so i cant get the correct column? And yes i'v run this in eclipse debugger aswell =)

Code related to this part:

private void init() {
    setDataSource();
    addGeneratedColumn("title", new TitleColumnGenerator());
    addGeneratedColumn("description", new DescriptionGenerator());
    setColumnExpandRatios();
    setItemDescriptionGenerator(new TooltipGenerator());
}

protected class TooltipGenerator implements ItemDescriptionGenerator{
        private static final long serialVersionUID = 1L;

        @Override
        public String generateDescription(Component source, Object itemId, Object propertyId) {
            TaskRow taskRow = (TaskRow)itemId;
            if("description".equals(propertyId)){
                return taskRow.getDescription();
            }else if("title".equals(propertyId)){
                return taskRow.getTitle();
            }else if("category".equals(propertyId)){
                return taskRow.getCategory().toString();
            }else if("operation".equals(propertyId)){
                return taskRow.getOperation().toString();
            }else if("resourcePointer".equals(propertyId)){
                return taskRow.getResourcePointer();
            }else if("taskState".equals(propertyId)){
                return taskRow.getTaskState().toString();
            }
            return null;
        }       
    }
1
Smells like a tough one.. This might be irrelevant, but what kind of data container are you using? Is the TaskRow object non-null? Does the table render otherwise just fine? Did you debug the method that calls generateDescription()?miq
All other objects are pointing correctly, im using my own data container that implements Hierarchical container interface. The container works great in all other ways, just not this.Marthin
The JavaDoc for the propertyId of the method generateDescription says: The propertyId of the cell, null when getting row description. Could this be related? But there's an alternate solution: why don't you create e.g. a Label in each column generator and don't set the description to it?janhink

1 Answers

1
votes

I have passed the source object as the itemId when adding an item to the tree.

Node node = ...;
Item item = tree.addItem(node);

this uses the object "node" as the id. Which then allows me to cast itemId as an instance of Node in the generateDescription method.

public String generateDescription(Component source, Object itemId, Object propertyId) {
    if (itemId instanceof Node) {
        Node node = (Node) itemId;
        ...

Maybe not the best solution, but it Works for me. Then again, I am adding items directly to the tree rather than using a DataContainer.