I am looking into replacing my Tomahawk tree2 with the RichFaces tree to get better AJAX support without having to support my own custom version. I am looking for the following functionality: (1) optional multiple-selection via checkboxes, (2) node-highlighting to show find results, (3) paged tree nodes (like a paged data table to limit the number of children shown), (4) ability to turn off standard node selection by clicking node (in case of multiple selection being enabled).
I have been looking at this for a couple of hours now and with some code most look feasible, but some is harder to find. Here is what I think so far:
(1) this one seems pretty easy, it simply looks like using a4j:support on the onclick of the check box in the node to toggle the node selection. The harder part seems that I have to overwrite the node state to allow for multiple selection. Also, I have to have that data in the rendering, and I don't see a way yet to determine in the child components to know if the current node is selected.
(2) Although there seems to be some highlighting support, it doesn't look fully implemented to me. I see the TreeNodeRenderer has the code:
getUtils().writeAttribute(writer, "rich:highlightedclass", variables.getVariable("highlightedClass") );but nowhere do I see an "isHighlighted(TreeRowKey)" or "setHighlighted(TreeRowKey)" or where I can get access to those during rendering.
(3) This one I can handle in a custom tree node. By overriding the getChildren() I can return a custom iterator that skips over certain nodes. Then I can programmatically add "previous" and "next" nodes that when selected scroll the nodes in the parent (once again having to be handled by the custom tree state probably).
(4) Not sure on this one, it looks the like default renderer has no option to turn this off. The code is a little hard to follow in the "TreeRendererBase", so I may have just missed it. At the very least, I can just use the node selection to also check/un-check the checkbox.
Has anyone done anything similar (multiple-selection, programmatically overriding the state, expansion, etc.) that has any pointers? Overall the tree seems to have the ability to do this, but the code is not straight forward and it seems like there is going to be a lot of custom code to do this as the tree seems to want to behave one way and is not very flexible without a lot of work to behave outside of this default way.