Page 1 of 2

Tree Collapse

Posted: 01 Jul 2009, 07:07
by ownzone
When I add/delete a node at any level in a tree, after successfull addition/deletion, the tree always gets collapsed.
How can I prevent this?

Thanks in advance :)

Re: Tree Collapse

Posted: 01 Jul 2009, 11:38
by cagatay.civici
Can you provide your code please?

Re: Tree Collapse

Posted: 02 Jul 2009, 15:39
by ownzone
Thanks for the response.

Say my initial tree structure is:
-Root Node
|------Node 1
|------Node 2
|------Node 3

I am able to add a node say Node 2-1 under the parent Node Node 2
But after adding, when the .jsp refreshes, the tree gets collapsed as follows:
+Root Node

I want to know how I can retain the Node level at which the sub-node is added, so that after adding the sub-node, the tree structure is as follows (with the added node highlighted):
-Root Node
|------Node 1
|------Node 2
----------|Node 2-1
|------Node 3

Please note that I am using Jackrabbit framework for the node creation/deletion

I am sharing the code as follows:

File: tree.jsp
<p:tree value="#{myTreeBean.model}"
cache="false"
toggleMode="client"
nodeSelectListener="#{myTreeBean.onNodeSelect}"
nodeExpandListener="#{myTreeBean.onNodeExpand}"
nodeCollapseListener="#{myTreeBean.onNodeCollapse}">
</p:tree>

File: faces-config.xml
<managed-bean>
<managed-bean-name>treeBean</managed-bean-name>
<managed-bean-class>com.dms.tree.TreeBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

File: TreeBean.java
public class TreeBean
{
private TreeNode root;

public TreeBean()
{
Session session = null;
try
{
.................
.................
.................

root = new TreeNode(initialNode.getName());
getAllNodes(initialNode, root);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
session.logout();
}
}

private void getAllNodes(Node node, TreeNode root) throws RepositoryException
{
// Format the Node/Sub-Node components
.................
.................
.................
}


public TreeNode getModel()
{
return root;
}
}

Re: Tree Collapse

Posted: 03 Jul 2009, 11:43
by ownzone
Hello Cahaty... waiting for an advice from you on this.
Thanks in advance...

Re: Tree Collapse

Posted: 06 Jul 2009, 16:18
by ownzone
Hi Cagaty... Any updates on this?

Re: Tree Collapse

Posted: 07 Jul 2009, 10:27
by cagatay.civici
Hi I guess you were referring to me as Cagaty or Cahaty.

Try with a bigger scope like session instead of request for your managed bean so that state will be kept after postback.

Re: Tree Collapse

Posted: 07 Jul 2009, 16:39
by ownzone
Dear Cagatay... sorry from the bottom of my heart for mis-spelling your name.

As advised, will try with session and let you know.

Re: Tree Collapse

Posted: 07 Jul 2009, 18:06
by cagatay.civici
Dear Cagatay... sorry from the bottom of my heart for mis-spelling your name.
No worries, I'm used to it ;)

Re: Tree Collapse

Posted: 09 Jul 2009, 15:42
by ownzone
Not working...
Any other suggestions?

Thanks in advance!!!

Re: Tree Collapse

Posted: 11 Jul 2009, 21:48
by ownzone
hello cagatay, it's me again...

all i want is that after the tree is rendered on a page, the onnodeclick event of a particular node needs to be triggered so that the coresponding documents' attached to the node is shown. i can now make that happen by clicking on that particular node.

Pl. suggest a solution...
Thanks in advance!!!