How to populate CellTree with data from the back

CellTree has a constructor that accepts a TreeModel. I cannot set the tree model using the setter.

I retrieve the data for the tree through an asynchronous rpc call, this call is triggered when a presenter is created that matches the view containing this tree, but this means that the view is also created without a tree model filled with the necessary data.

When the data returns, I set the node root to the model, but the model is already created without the root, so it does not receive the update ...

I went along this route because I want to better control the rendering of tree nodes.

Two possible solutions ...

  • Hold the view render until the selection returns, so when the tree is created, the model will have all the information. How to do it?

  • As soon as the data returns and is installed in the model, tell the tree to update ... How to do this?

+4
source share
2 answers
  • When you create a view, you must configure CellTree on top of the ListDataProvider .
  • When you receive an RPC call for data transfer, you update the ListDataProvider, your CellTree will be updated and re-displayed automatically.

Read the Dynamic Data Submission Developer's Guide - Cell Widgets. Heres a quick quote:

ListDataProvider binds your cell widget to java.util.List. Any changes to the internal list that can be accessed via getList () will be displayed in the views. Views are updated at the end of the current event block, so you can make several synchronous changes without causing the views to be updated multiple times.

+3
source

Using ListDataProvider or AsyncDataProvider (if you want to dynamically update the table with data, rather than loading everything all at once), this will work just fine for you.

0
source

All Articles