Board index JavaServer Faces General Tree Collapse

Tree Collapse

Components, Ajax Framework, Utilities and More.

Post 01 Jul 2009, 07:07

Posts: 16
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 :)

Post 01 Jul 2009, 11:38

Posts: 15103
Location: Cybertron

Can you provide your code please?
PrimeFaces Lead

Post 02 Jul 2009, 15:39

Posts: 16
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;
}
}

Post 03 Jul 2009, 11:43

Posts: 16
Hello Cahaty... waiting for an advice from you on this.
Thanks in advance...

Post 06 Jul 2009, 16:18

Posts: 16
Hi Cagaty... Any updates on this?

Post 07 Jul 2009, 10:27

Posts: 15103
Location: Cybertron

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.
PrimeFaces Lead

Post 07 Jul 2009, 16:39

Posts: 16
Dear Cagatay... sorry from the bottom of my heart for mis-spelling your name.

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

Post 07 Jul 2009, 18:06

Posts: 15103
Location: Cybertron

Dear Cagatay... sorry from the bottom of my heart for mis-spelling your name.


No worries, I'm used to it ;)
PrimeFaces Lead

Post 09 Jul 2009, 15:42

Posts: 16
Not working...
Any other suggestions?

Thanks in advance!!!

Post 11 Jul 2009, 21:48

Posts: 16
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!!!

Next

Return to General