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
Tree Collapse
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Can you provide your code please?
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;
}
}
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;
}
}
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
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.
Try with a bigger scope like session instead of request for your managed bean so that state will be kept after postback.
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
No worries, I'm used to itDear Cagatay... sorry from the bottom of my heart for mis-spelling your name.
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!!!
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!!!
-
- Information
-
Who is online
Users browsing this forum: No registered users and 7 guests