I want to export the entire page to front end application. The page may contain 1 or 2 text component and image etc. Need to expose all of it is content. for example, http://localhost:4502/editor.html/content/we-retail/language-masters/en/men.model.tidy.json. This will give me the entire page content but along with some misc properties, like lastModifiedDate, allowedComponents, replicatedBy.
Is there a way to exclude these properties (lastModifiedDate, allowedComponents etc)?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Mario248 ,
Ideally you should not customised existing servlet. If your page structure is fixed or at least you know combinations of components. Then you can easily write a resource type servlet to expose/export required custom content. Add some different selector to differentiate from default servlet.
Hi @Mario248 ,
As per @Pallavi_Shukla_ suggested yes, you can do it through Sling Model Exporter by annotating @JsonIgnore to the variable which you don't want to expose.
fore more details please have a look at this article: https://experienceleague.adobe.com/docs/experience-manager-learn/foundation/development/develop-slin...
Hope that helps you!
Regards,
Santosh
Yeah I know we can create a model class for a specific component meaning we can create a model class for specific resource type but how do we do it for the entire page? like in my description, I want to export the entire page (/content/we-retail/language-masters/en/men.model.tidy.json) meaning all the component content to be exported. how do we do this at page level ?
Also please tell if we can tweak OOTB exporter with exclude properties ?
@Mario248 honestly, I'm not sure whether we can able to tweak OOTB API.
However, to answer your first question - please refer this article to customize page properties: https://www.linkedin.com/pulse/how-customize-properties-image-converted-json-aem-65-ragul-r
Hi,
This is PoC I created for exporting content as json
https://aemlab.blogspot.com/2019/07/get-json-response-of-aem-page.html
The SlingModelExporter itself does not know about the concept of a page, it just knows itself (a model object), and it can serialize all its members into JSON.
That means if you want to export the page itself as a hierarchical JSON structure, your models needs to have references to all sub-models (which themselves can have references to their own sub-models). That should work, although I have never tried it out myself.
The problem is most often on the consuming side, as the result most likely resembles the component model of the page 1:1, thus often creating a very flexible (read: unpredictable) JSON, which is hard consume programmatically. Probably that's the reason why there's not much tooling available fro it.
Thank you for your valuable input.
Hi @Mario248 ,
Ideally you should not customised existing servlet. If your page structure is fixed or at least you know combinations of components. Then you can easily write a resource type servlet to expose/export required custom content. Add some different selector to differentiate from default servlet.
Thank you for your valuable input