I have the following path:
/content/mysite/en/jcr:content/content/section/par_0
/content/mysite/en/jcr:content/content/section/par_1
/content/mysite/en/jcr:content/content/section/par_1/oldnode
I want to add another node before the RTE node. It seems I need to be using orderBefore function but I cannot get it to work.
I tried
Node mynode = session.getNode("/content/mysite/en/jcr:content/content/section/par_1);
mynode.orderBefore("oldnode", "newnode")
and I'm getting a "not a child error".
Any ideas? Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
@jayv25585659 For orderBefore to work properly ,
Node mynode = session.getNode("/content/mysite/en/jcr:content/content/section/par_1);
mynode.orderBefore("oldnode", "newnode")
Your myNode should be the parent node , and first argument should be your node name ( you want to insert) and second argument should be the the node name immediately below which you want to insert it.
orderBefore
void orderBefore(java.lang.String srcChildRelPath, java.lang.String destChildRelPath) throws UnsupportedRepositoryOperationException, VersionException, ConstraintViolationException, ItemNotFoundException, LockException, RepositoryException
If this node supports child node ordering, this method inserts the child node at srcChildRelPath into the child node list at the position immediately the child node at destChildRelPath.
To place the node srcChildRelPath at the end of the list, a destChildRelPath of null is used.
Also please refer some sample her https://www.codota.com/code/java/methods/javax.jcr.Node/orderBefore
Hope this helps
Thanks
Veena
@jayv25585659 For orderBefore to work properly ,
Node mynode = session.getNode("/content/mysite/en/jcr:content/content/section/par_1);
mynode.orderBefore("oldnode", "newnode")
Your myNode should be the parent node , and first argument should be your node name ( you want to insert) and second argument should be the the node name immediately below which you want to insert it.
orderBefore
void orderBefore(java.lang.String srcChildRelPath, java.lang.String destChildRelPath) throws UnsupportedRepositoryOperationException, VersionException, ConstraintViolationException, ItemNotFoundException, LockException, RepositoryException
If this node supports child node ordering, this method inserts the child node at srcChildRelPath into the child node list at the position immediately the child node at destChildRelPath.
To place the node srcChildRelPath at the end of the list, a destChildRelPath of null is used.
Also please refer some sample her https://www.codota.com/code/java/methods/javax.jcr.Node/orderBefore
Hope this helps
Thanks
Veena
Views
Likes
Replies
Views
Likes
Replies