Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

How to get a Json for a page model which I am calling through customheaderlibs.html

Avatar

Level 1

1st method: I have an exporter model without any resource type, this is generally a page model. When I call this model through customheaderlibs.html, it is getting called on page load but I am unable to see any JSON for the same, want to get Json for the getters inside the model.


This model Json we will pass to react team and they will help see seo data based on it, which will be visible in view page source.
as this is a spa project where we have headless aem and no component htl, we are integrating with react for the view and page source.

 

when there was no headless then we were using metadat.html for the same, but now getting difficulty in the headless approach where we have to get the same model data as json. 

Note: data in model is getting populated from page properties.

@arunpatidar  @lukasz-m  @kautuk_sahni 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

I don't know if I understood correctly your question, but I see clearly a couple of misunderstood concepts, let me guide you on how I think you should face this:

- The SlingModel exporter requires a selector and a resourceType in order to be invoked, the result of this invocation is a JSON output, which I assume is what you will pass to your react team. Please check this to understand how you can achieve this: https://experienceleague.adobe.com/docs/experience-manager-learn/foundation/development/develop-slin...

- The SlingModel exporter relies on the Jackson framework, which in short, will produce a JSON output based on the "getters" method found in your SlingModel, that means, if you add, for example, a method called getPageName(), the final JSON output will append a property called "pageName" and the value will be the return statement from the getPageName() method. 

- The core components had implemented the "ComponentExporter" for the resourceType "page", this is a default implementation that you can take advantage of, you can learn more here about it: https://experienceleague.adobe.com/docs/experience-manager-65/developing/components/json-exporter-co.... But this is a default "basic" implementation, you can inherit and built on top of it or you can create your own implementation which suits your needs.

 

Hopefully this clarify your doubts.



Esteban Bustamante

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

I don't know if I understood correctly your question, but I see clearly a couple of misunderstood concepts, let me guide you on how I think you should face this:

- The SlingModel exporter requires a selector and a resourceType in order to be invoked, the result of this invocation is a JSON output, which I assume is what you will pass to your react team. Please check this to understand how you can achieve this: https://experienceleague.adobe.com/docs/experience-manager-learn/foundation/development/develop-slin...

- The SlingModel exporter relies on the Jackson framework, which in short, will produce a JSON output based on the "getters" method found in your SlingModel, that means, if you add, for example, a method called getPageName(), the final JSON output will append a property called "pageName" and the value will be the return statement from the getPageName() method. 

- The core components had implemented the "ComponentExporter" for the resourceType "page", this is a default implementation that you can take advantage of, you can learn more here about it: https://experienceleague.adobe.com/docs/experience-manager-65/developing/components/json-exporter-co.... But this is a default "basic" implementation, you can inherit and built on top of it or you can create your own implementation which suits your needs.

 

Hopefully this clarify your doubts.



Esteban Bustamante