Hi all,
//Create a Session
javax.jcr.Session session = repository.login(
new
SimpleCredentials(
"admin"
,
"admin"
.toCharArray()));
//Create a node that represents the root node
Node root = session.getRootNode();
// Create Node
Node n2 = root.getNode("content/mysite/ mypage/jcr:content/n1/n2")
Node n3 = root.addNode(
"n3"
);
// Create Node
Node n1 = root.getNode("content/mysite/ mypage/jcr:content/n1")
Node n11 = root.addNode(
"n11"
);
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
If you see the documentation you may find that "addNode()" function accepts the relative path. Its is not aware of any level structure.
Now lets say you call root.addNode("x1"); in this case root path is mypage/jcr:content so mypage/jcr:content/x1 gets created.
From here if you want to creates node under mypage/jcr:content/x1 you need to change the reference from which you calling.
Node n = session.getNode("mypage/jcr:content/x1").
Node x2 = n.addNode("x2");
Now this will create a node similar to mypage/jcr:content/x1/x2.
Keep in mind that its relative path to the node from which you are calling it.
Views
Replies
Total Likes
Hi,
If you see the documentation you may find that "addNode()" function accepts the relative path. Its is not aware of any level structure.
Now lets say you call root.addNode("x1"); in this case root path is mypage/jcr:content so mypage/jcr:content/x1 gets created.
From here if you want to creates node under mypage/jcr:content/x1 you need to change the reference from which you calling.
Node n = session.getNode("mypage/jcr:content/x1").
Node x2 = n.addNode("x2");
Now this will create a node similar to mypage/jcr:content/x1/x2.
Keep in mind that its relative path to the node from which you are calling it.
Views
Replies
Total Likes
Views
Like
Replies