-1

when i'm creating a new page i want to get a parent page property. I create a custom combofield with nodes from a specific path, but i need a parent page property to complete my path. Any idea?

session = MgnlContext.getJCRSession(myWorkspace)
foundNode = session.getNode("/"+ parentPageProperty);
NodeIterator childrenIterator = foundNode.getNodes();
Iterable<Node> childrenIterable = NodeUtil.asIterable(childrenIterator);
List<Node> allNodes = NodeUtil.asList(childrenIterable);
pacheco
  • 13
  • 3

1 Answers1

0

I assume you want to reach to the root node, if that's the case you can do the following:

Node rootNode = session.getRootNode();
rootNode.getProperty("ofChoice");

Cheers,

Ducaz035
  • 3,054
  • 2
  • 25
  • 45
  • thanks, but i dont want the rootnode, i want the parent node, thanks anyway – pacheco Aug 07 '17 at 15:59
  • then you can do session.getNode("nodePath").getParent(); – Ducaz035 Aug 07 '17 at 17:20
  • i know that, but i'm want know parent node where i am in dialog, creating the new node – pacheco Aug 08 '17 at 15:03
  • Sorry I still don't get it, can you elaborate it further ? I understood that you want to get a parent node of something but it shall be parent node of what ? – Ducaz035 Aug 09 '17 at 07:40
  • when i create a new node, i want to check the parent's properties – pacheco Dec 18 '17 at 14:54
  • If you are talking about creating a new page, you will hit to info.magnolia.pages.app.action.CreatePageAction. There you see JcrNodeAdapter. With that object you can do the following: Node createdNode = itemChanged.getJcrItem(); Node parentNode = createdNode.getParent(); PropertyIterator parentNodeProperties = parentNode.getProperties(); – Ducaz035 Dec 18 '17 at 15:02