-
1. Re: How to preserve tree state betwean page requests?
maksimkaszynski Sep 22, 2007 3:28 PM (in response to stef5636)Actually, tree stores all the expanded nodes, unless its told not to do it.
Please attach your page code. -
2. Re: How to preserve tree state betwean page requests?
stef5636 Sep 24, 2007 3:47 AM (in response to stef5636)I have a rich tree in facelets template.
<ui:include src="tree.xhtml" />
in tree.xhtml is:
<rich:tree toggleOnClick="true">
<rich:treeNodesAdaptor var="item" nodes="#{brands}">
<rich:treeNode >
<h:outputText value="#{item.nameDecode}"/>
</rich:treeNode>
<rich:treeNodesAdaptor var="grp" nodes="#{treelists.getGroups(item.id)}">
<rich:treeNode>
<h:outputText value="#{grp.nameDecode}"/>
</rich:treeNode>
<rich:treeNodesAdaptor var="subgrp" nodes="#{treelists.getSubGroups(item.id, grp.id)}">
<rich:treeNode>
<s:link action="list" value="#{subgrp.nameDecode}">
<f:param name="p" value="#{item.id}"/>
<f:param name="g" value="#{grp.id}"/>
<f:param name="s" value="#{subgrp.id}"/>
</s:link>
</rich:treeNode>
When click on the link, will show other page, but with tree in left. The question is, how to show the tree, opened at same leaf? -
3. Re: How to preserve tree state betwean page requests?
maksimkaszynski Sep 24, 2007 10:40 AM (in response to stef5636)Actually, the problem is in that when you have only ajax requests, and then perform refresh, JSF doesn't recognize it as postback, and therefore doesn't restore view state. So if you want your page to be correctly refreshed, use varState attribute to save tree state in session-scoped bean.
-
4. Re: How to preserve tree state betwean page requests?
stef5636 Sep 24, 2007 12:13 PM (in response to stef5636)example, please? How to use varState?
What type must be variable in Session Bean?
Thanks for answer! -
5. Re: How to preserve tree state betwean page requests?
nightiger Oct 1, 2007 10:58 AM (in response to stef5636)varState or stateVar ??????
-
6. Re: How to preserve tree state betwean page requests?
maksimkaszynski Oct 2, 2007 12:40 PM (in response to stef5636)Looks that I mislead you a bit. Next example works
Tree on the page<rich:tree style="width:300px" height="400px" switchType="ajax" componentState="#{simpleTreeBean.treeState}"> <rich:recursiveTreeNodesAdaptor roots="#{fileSystemBean.sourceRoots}" var="item" nodes="#{item.nodes}" /> </rich:tree>
Piece of session beanprivate TreeState treeState; public TreeState getTreeState() { return treeState; } public void setTreeState(TreeState treeState) { this.treeState = treeState; }
-
7. Re: How to preserve tree state betwean page requests?
maksimkaszynski Oct 2, 2007 12:41 PM (in response to stef5636)Notice componentState binding. It maps to field of type org.richfaces.component.state.TreeState