I need to retrieve the internal node structure(which is nothing but including the node structure of how the components of the page are stored in the JCR) of the page and render the UI giving the path of the page in aem6.3. Can anyone help me out?
Views
Replies
Total Likes
Try this String nodePath = "/content/community-components/en"; try { Node node = null; NodeIterator nodes =null; String result=""; resource = slingRequest.getResourceResolver().getResource(nodePath); if(resource != null) { node = resource.adaptTo(Node.class); NodeIterator nodeItr = node.getNodes(); while(nodeItr.hasNext()) { Node cNode = nodeItr.nextNode(); result=node.getProperty("jcr:primaryType").getValue().getString(); out.print(result); } } } catch(Exception e) { out.print(e); } or http://keysandstrokes.info/aem-code-snippets-read-child-nodes-aem/
Views
Replies
Total Likes
Can you please let me know whether retrieval of the data in json format which is achieved using javascript use-api in aem6.3?
Views
Replies
Total Likes
use the below js to get page nodes use(function () { var pageName = currentPage.name; var title = currentPage.properties.get("jcr:title"); var resourceName = granite.resource.name; var resourceTitle = properties.get("jcr:title"); return { pageName: pageName, title: title, resourceName: resourceName, resourceTitle: resourceTitle }; }); refer to examples here https://helpx.adobe.com/experience-manager/htl/using/use-api-javascript.html
Views
Replies
Total Likes
use these objects to get node structure https://helpx.adobe.com/experience-manager/htl/using/global-objects.html
Views
Replies
Total Likes
What business case are you supporting with this information. Purhaps there is another way to achieve your requirements.
Views
Replies
Total Likes
In the above image 'fr' is the page while giving the path of the page in the UI, it should retrieve the nodes and properties of them in a particular format(preferably in json), Is there anyways to do it using javascript use apis or anyother means?
Views
Replies
Total Likes
Hi Malarvizhi Saravanan :
I would suggest you to use AEM's Content Services to achieve what you want.
I is the best solution to your problem, giving you granular control over the data you would like to expose via the API.
Cheers,
Jagjeet
Views
Replies
Total Likes
Is there any other means to do with JCR Node API to achieve this?
Views
Replies
Total Likes
https://docs.adobe.com/docs/en/spec/jsr170/javadocs/jcr-1.0/javax/jcr/NodeIterator.html
<%
String nodePath = "/content/community-components/en";
try
{
Node node = null;
NodeIterator nodes =null;
String result="";
resource = slingRequest.getResourceResolver().getResource(nodePath);
if(resource != null)
{
node = resource.adaptTo(Node.class);
NodeIterator nodeItr = node.getNodes();
while(nodeItr.hasNext())
{
Node cNode = nodeItr.nextNode();
result=node.getProperty("jcr:primaryType").getValue().getString();
out.print(result);
}
}
}
catch(Exception e)
{
out.print(e);
}
%>
Views
Replies
Total Likes
You can create the structure using "infinity.json". For Example, if the page path is "/content/we-retail/ca/en/men" you can get the data from "/content/we-retail/ca/en/men.infinity.json" by using javascript(ajax call)
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies