Hi All,
I need to create a custom Servlet code where we need to iterate over the children and grandchildren of components on a certain page to create the output json of those components. We could do it using infinity.json OOTB , but we dont want to use the same as those are not recommended to be used in production . also we dont need to output all the components as json , we need to output as per the resource type.
Does anyone has any pointer or reference code to achieve the same.
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
you can check code here
Views
Replies
Total Likes
Hi @tnik,
I think you do not need servlet to achieve your goal. Use Sling Model Exporters feature instead.
Please explore official Adobe documentation to get full set of information in terms of Sling Model Exporter concept and implementation guides:
Views
Replies
Total Likes
Hi Lukasz-m ,
The issue is if we add sling model exporter to the components , we need to invoke them on 1 to 1 basis as per the component path , if we hit the Page path , it does not return the json for the components. We have already tried that
Thanks
Views
Replies
Total Likes
hi As mention by @lukasz-m , model.json must do a job.
but if you think you need a custom solution, I created something similar for PoC, you can test try that out
https://aemlab.blogspot.com/2019/07/get-json-response-of-aem-page.html
Views
Replies
Total Likes
@arunpatidar model.json is not returning the json for custom component on hitting the page directly , if we give the component path then it returns the expected json.
Also regarding the POC you did , does it exports all the custom properties of all the components on the page?
Thanks
Views
Replies
Total Likes
I want to loop the nodes as per resource types , but each component has different structure so how did you manage the component nodes to fetch properties from each one of them
Thanks
Views
Replies
Total Likes
Hi,
you can check code here
Views
Replies
Total Likes
Hi,
Yes, it basically look for all the nodes inside jcr:content(similar to infinity.json) and export as json.
There is a possibility to blocklist properties
Views
Replies
Total Likes
Thanks @arunpatidar , this what we were looking for , i assume the solution is compatible with AEMaaCS
Views
Replies
Total Likes
Views
Likes
Replies