Sometimes when I set the selectedItem of a Tree after changing its dataprovider, the application freezes :
when I debug and look at the collectionIterator of the Tree, it still has information of the old dataprovider, and the ListBase.setSelectionDataLoop enters an infinite loop.
I tried to set the selectedItem in a callLater, and call :
tree.invalidateList();
tree.invalidateSize();
tree.invalidateDisplayList();
tree.validateNow();
and it works in most of the cases, but in some cases my application still freezes.
Do you know how can I be sure to update my Tree before I set the selectedItem ?
It seems I validated everything but what is needed : the properties.
To make it work, I replaced :
tree.invalidateList();
tree.invalidateSize();
tree.invalidateDisplayList();
tree.validateNow();
with:
tree.validateProperties();
When I was stucked in an infinite loop in setSelectionDataLoop, I noticed the dataProviderChanged flag was true. If I validate the properties before I set the selectedItem then it works fine.
If selectedItem did not work, it may remain an inconsistence between the dataProvider and what is displayed :
If you use selectedIndex you may have a wrong behaviour, for example :
you add an item to the dataProvider, and set selectedIndex to "dataProvider.length -1" but the view is not ready for the new dataprovider and does not know any item at this index.
North America
Europe, Middle East and Africa
Asia Pacific