Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Insert node after concrete sibling node

Anton_Smulskiy
Level 3
Level 3

Hi,

I have a node structure like:

parsys

- component1

- component2

- component3

- component4

And I need to add 'newComponent' node after 'component2' programmatically.

The result should be:

parsys

- component1

- component2

- newComponent

- component3

- component4

Can't find a way how to add newComponent node to have that order. Can anyone help? Thanks.

1 Reply
raj_mandalapu
Community Advisor
Community Advisor

First, you need to create a node using node.addNode() then using below code you can change the order

  • Get the recently created node.
  • Get the node and name
  • Use below code

contentNode.orderBefore(dscNode,destNode);

contentNode.save();

Node (Content Repository for Java Technology API Version 2.0)