How to hide some nodes in Richfaces Tree (do not render nodes by condition)?
Posted
by VestniK
on Stack Overflow
See other posts from Stack Overflow
or by VestniK
Published on 2010-05-28T17:34:32Z
Indexed on
2010/05/30
20:22 UTC
Read the original article
Hit count: 339
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?
© Stack Overflow or respective owner