Hi,
I’m facing a little refresh problem while trying to implement a lazy loading tree with Vaadin (6.2.6) : I’ve added an expand listener to the tree that checks if the expanded item was already loaded, and if not, asynchronously retrieves it’s children (as a http get request to a REST service that produces JSON, but that’s beside the point).
Here is basically what my code looks like :
@Override
public void nodeExpand(final ExpandEvent event) {
ContentReponse content = ... //parsed from the json response
//iterate over the response entries
for (RepositoryEntry entry : content.content) {
Item item = tree.addItem(entry.name); //create a new item in the tree
tree.setParent(entry.name, event.getItemId()); //sets the new item's parent
}
:
: // <-- here
}
This sort of works : when I expand a node “N” in the tree, the listener is fired and the data is retrieved, but the newely retrieved node children are not shown, which is to be expected, since their retrieval doesn’t block Vaadin from returning the reply.
But then, any following expand/collapse I perform on any other node in the tree expands the node “N” and shows it’s children.
Is there a way to force the tree, or even better : a node, to update itself ? I’m guessing it should go where I placed the “// ← here” in my code snippet.
I tried tree.requestRepaint but to no avail.
Thanks !
Edit:
Just saw this thread : http://vaadin.com/forum/-/message_boards/message/131802#_19_message_131949 (which wasn’t yielded by any of the searches I made before posting this message ?). I’m doing basically the same thing Marko Grönroos did in his code example and yet I’m experiencing the weird behaviour described above.
If this helps, the tree update is performed by a different thread than the request’s thread. I took care to enclose my code in a synchronisation block on Vaadin’s Application instance :
synchronized(tree.getApplication()){
:
:
}