I have a tree of categories and courses in my SEAM application. Courses may be active and inactive. I want to be able to show only active or all courses in my tree.
I've decided to always build complete tree in my PAGE scope component since building this tree is quite expensive operation. I have boolean flag courseActive in the data wrapped by TreeNode<T>. Now I can't find the way to show courses node only if this flag is true.
The best result I've achieved with the following code:
<h:outputLabel for="showInactiveCheckbox" value="show all courses: "/>
<h:selectBooleanCheckbox id="showInactiveCheckbox" value="#{categoryTreeEditorModel.showAllCoursesInTree}">
<a4j:support event="onchange" reRender="categoryTree"/>
</h:selectBooleanCheckbox>
<rich:tree id="categoryTree" value="#{categoryTree}" var="item" switchType="ajax"
ajaxSubmitSelection="true" reRender="categoryTree,controls"
adviseNodeOpened="#{categoryTreeActions.adviseRootOpened}"
nodeSelectListener="#{categoryTreeActions.processSelection}"
nodeFace="#{item.typeName}">
<rich:treeNode type="Category" icon="..." iconLeaf="...">
<h:outputText value="#{item.title}"/>
</rich:treeNode>
<rich:treeNode type="Course" icon="..." iconLeaf="..."
rendered="#{item.courseActive or categoryTreeEditorModel.showAllCoursesInTree}">
<h:outputText rendered="#{item.courseActive}" value="#{item.title}"/>
<h:outputText rendered="#{not item.courseActive}" value="#{item.title}" style="color:#{a4jSkin.inactiveTextColor}"/>
</rich:treeNode>
</rich:tree>
the only problem is if some node is not listed in any rich:treeNode it just still shown with title obtained by Object.toString() method insted of being hidden.
Does anybody know how to not show some nodes in the Richfases tree according to some condition?
Update
For better understanding what I'm trying to do I can provide simple example:
Imagune that I have a filesystem with files and directories and there are normal and hidden files (in my case I have no hidden directories but it's not important).
I want to read files and directories once and store the tree in the model (org.richfaces.model.TreeNode) and then be able to show only directories on one page and only directories and not hidden files by default on another page with possibility to show all files and directories using checkbox on this page.
There is not enough to hede(/not render) rish:treeNode element in facelet since if there is a node which is not mentioned in any of rendered rich:treeNode this node is rendered using default icons and title. One may think about rich:treeNode like about an elemnt only to add custom visual style to nodes of some types but not as an element responsible for rendering of a node.