Tree Collapse

UI Components for JSF
ownzone
Posts: 16
Joined: 01 Jul 2009, 07:03

01 Jul 2009, 07:07

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

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

01 Jul 2009, 11:38

Can you provide your code please?

ownzone
Posts: 16
Joined: 01 Jul 2009, 07:03

02 Jul 2009, 15:39

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;
}
}

ownzone
Posts: 16
Joined: 01 Jul 2009, 07:03

03 Jul 2009, 11:43

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

ownzone
Posts: 16
Joined: 01 Jul 2009, 07:03

06 Jul 2009, 16:18

Hi Cagaty... Any updates on this?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

07 Jul 2009, 10:27

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.

ownzone
Posts: 16
Joined: 01 Jul 2009, 07:03

07 Jul 2009, 16:39

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

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

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

07 Jul 2009, 18:06

Dear Cagatay... sorry from the bottom of my heart for mis-spelling your name.
No worries, I'm used to it ;)

ownzone
Posts: 16
Joined: 01 Jul 2009, 07:03

09 Jul 2009, 15:42

Not working...
Any other suggestions?

Thanks in advance!!!

ownzone
Posts: 16
Joined: 01 Jul 2009, 07:03

11 Jul 2009, 21:48

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!!!

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 19 guests