Tree controls require something similar, but more complex
So my best guess would be that you'd attach a "click" AJAX event to nodes and have the event handler check the clicked node to see if its child list had been populated, and if not (or if stale), then populate it
But consider a common case where you have a 3-level menu tree of Country, State/Province, City.
So you can (and should) simplify your thinking by casting it in terms of the simpler Views and Models.
If I'm not mistaken, the tree's "selection" attribute will indicate which node was actually initiating the event
If PrimeFaces doesn't have direct support for anything more dynamic, you can do it the hard way, which is to add a "binding=" attribute to the p:tree element and construct TreeNodes in Java code when the AJAX listeners fire.
I want to correct a common misconception. JPA Models (also known as Persistence Models or Object Models) are NOT the same thing as JSF's GUI Modes
When I said "dynamic"
Well, here's another context. A dataTable uses a DataModel as its Model façade. It does this because the DataModel can wrap a POJO model, but adds some useful JSF-specific features, much like the TreeNode does for PrimeFaces trees.
As far as I know, however, the PrimeFaces doesn't automatically generate TreeNode objects. So if you change the data model, you'd have to manually add/remove TreeNodes and map them to the corresponding added/removed data model objects.
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton