dimanche 22 février 2015

AEM Get child node content


How do you get child node content with JavaScript specifically?


I am able to get the parent node information by using the following:


granite.resource.properties


However I need to have access to a child node


-parent


-- child (named image)


There are ways to get access to the child node with Java but I am building a JavaScript only solution:


Java Example below



for (Node n1 : JcrUtils.getChildNodes(node)){
String imagePath = n1.getPath().toString();
Resource imageResource = resourceResolver.getResource(imagePath);
Node imageNode = imageResource.adaptTo(Node.class);
ValueMap imageNodeProps = imageResource.adaptTo(ValueMap.class);
String imageName = null;
imageName= imageNodeProps.get("fileReference", "None");




Aucun commentaire:

Enregistrer un commentaire