Get node currenPage form in CQ5

I have a component that should retrieve properties from another component on the same page.

Is there a way to get a component NODEfrom currentPage?

I have a name node I need to get available code.

+4
source share
3 answers

Assuming node you need Page/jcr:content/yournode:

The object Pagehas a method getContentResource()that by default returns you the jcr:contentnode resource . You can also use page.getContentResource("yournode")to get a specific node below jcr:content.

node, - jcr:content ( btw), resource.listChildren().

, Sling API, , . JCR node resource.adaptTo(Node.class)

+9

jcr:content, :

Node node = CurrentPage.getContentResource("COMPONENTNAME").adaptTo(Node.class);

, Node.

, node, Node.

String title = node.getProperty("jcr:title").getString();

.

+1

, , , - . , ,

, ,

  var url = CQ.HTTP.addParameter(dialog.path + '.validator.json', 'value', value);
  var result = CQ.HTTP.eval(url);

 and in the servlet we access the node and its parents using below logic
   final Node currentNode = request.getResource().adaptTo(Node.class);
   try {
        final Node par = currentNode.getParent();

        final NodeIterator nodes = par.getNodes();

        // get all form names for the current paragraph system
        while (nodes.hasNext()) { //and the business logic
0
source

All Articles