Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

tree related question

Ngadhnjim Berani
7 years ago Aug 26, 2015 12:48pm
Kim Leppänen
7 years ago Aug 27, 2015 5:08am
Ngadhnjim Berani
7 years ago Aug 27, 2015 8:32am
Kim Leppänen
7 years ago Aug 27, 2015 8:53am

getItem() takes as its parameter an item ID, which in your case would be the MyOwnType. So someObjectOfMyOwnType is your MyOwnType. I don't quite understand what you are trying to achieve.

If you just need to update a property of the parent whenever you add a child, then you should have own application logic for that. For example, something in the these lines

public void addChild(MyOwnType object, MyOwnType parent) {
    Item item = container.addItem(object);
    // populate item properties

    Item parentItem = container.getItem(parent);
    if(parentItem != null) {
       parentItem.getItemProperty("counter").setValue(object.getChildren().size());
    }

    for(MyOwnType child : object.getChildren()) {
       addChild(child, object);
    }
}

 

Ngadhnjim Berani
7 years ago Aug 27, 2015 9:28am
Kim Leppänen
7 years ago Aug 27, 2015 9:41am
Ngadhnjim Berani
7 years ago Aug 27, 2015 9:56am