-
1. Re: Remebering tree expanded state
mail.micke Nov 13, 2007 6:12 AM (in response to mail.micke)Forgot to mention that I want it working with client switchType.
-
2. Re: Remebering tree expanded state
fmarwede Nov 13, 2007 6:55 AM (in response to mail.micke)I'm very interested in this too.
-
3. Re: Remebering tree expanded state
mail.micke Nov 19, 2007 6:25 AM (in response to mail.micke)I still haven't solved this completely.
When using componentState attribute with TreeState class the state is saved when using ajax type tree. But with client and server switch type it doesn't work.
Any pointers greatly appreciated.
- Mike -
4. Re: Remebering tree expanded state
mail.micke Nov 29, 2007 4:43 AM (in response to mail.micke)This is the last ping,
then I'll just assume this isn't possible currently.
A simple anwser like "it is easy, read the docs" will suffice ;) -
5. Re: Remebering tree expanded state
pankaj.ghosh Dec 5, 2007 10:13 AM (in response to mail.micke)I am sort of stuck in the same scenario.
Does anyone made any breakthroughs in this?
Thanks
Pankaj -
6. Re: Remebering tree expanded state
fmarwede Dec 5, 2007 10:30 AM (in response to mail.micke)Hmm...it seems to me, only people who want this feature read this thread ;-)
I still don't know how to do this - until someone explains how to do it on client side I do it on server side. With a lot of self written code because I didn't get the "normal way" (explained in the docs) working.
Still another reason for asking about a smart and stylish way to do it on client side :-) -
7. Re: Remebering tree expanded state
pankaj.ghosh Dec 5, 2007 10:48 AM (in response to mail.micke)Can you post a code snippet of how to go about it from server side?
-
8. Re: Remebering tree expanded state
fmarwede Dec 5, 2007 11:27 AM (in response to mail.micke)Yes, I can :-)
First I use jsFunction to define to methods for collapsing/expanding a selected node (incl. its subtree):<a4j:jsFunction name="expandNode" action="#{ctrl.expandTreeNav}" ajaxSingle="true" reRender="TreeNavigator"> <a4j:actionparam name="node" assignTo="#{ctrl.currentNode}"/> </a4j:jsFunction> <a4j:jsFunction name="collapseNode" action="#{ctrl.collapseTreeNav}" ajaxSingle="true" reRender="TreeNavigator"> <a4j:actionparam name="node" assignTo="#{ctrl.currentNode}"/> </a4j:jsFunction>
These methods I call with a self written context menu. I hope we can use the richfaces context menu for that soon.
Further I use a binding in my rich:tree<rich:tree value="#{ctrl.treeNavData}" var="item" nodeFace="#{item.type}" showConnectingLines="true" switchType="ajax" binding="#{ctrl.treeNavBinding}"> ... </rich:tree>
The java code is the complicated part: First I use on initial tree building a recursive method to set a ListRowKey to each node, to identify them later. Second we need the java methods we call with the jsFunctions. One looks like this:public void expandTreeNav() { TreeState state = (TreeState) treeNavBinding.getComponentState(); TreeNavigationNode node = (TreeNavigationNode) getDescendant(treeNavData, currentNode); try { recursiveExpandFromAncestor(state, node); } catch (IOException e) { // TODO When there's a concept do a proper exception handling here. e.printStackTrace(); } }
The used methods here are (as you'll guess) another recursive methods to navigate through the tree.
I have warned you: Lots of self written code. -
9. Re: Remebering tree expanded state
mail.micke Dec 5, 2007 11:40 AM (in response to mail.micke)Hi
fmarwede, have you tried using the componentState attribute and bind that to a TreeState object on the backing bean(session scoped) ?
That works for me when the switchType is ajax for the tree.
But still no solution for client or server side switchType's ...
Cheers -
10. Re: Remebering tree expanded state
fmarwede Dec 5, 2007 11:57 AM (in response to mail.micke)Exact like this.
-
11. Re: Remebering tree expanded state
seammer Dec 15, 2007 11:36 AM (in response to mail.micke)In tree2 there is treeState and treeStateBase can solve such problem with very few code.
However, I couldn't find the similar part as treeStateBase in richfaces... -
12. Re: Remebering tree expanded state
barbaraboie Oct 20, 2010 4:54 AM (in response to seammer)Hello
I have the same problem. Is there in meantime a solution to keep the state of a tree with switchType="client"?
Barbara