Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

CaaS for a page content in aem

Avatar

Level 3

Is there any way to display content of a  page like a sling model json. For example : if i have a page "/content/my-site/homepage" & it contains three components a,b,c . Each component has a sling model. if i hit the component path("/content/my-site/homepage/jcr:content/a.model.json") directly with .model.json extension then it will give a json view of that component as i'm using jackson exporter in sling model. i want to display the json of all the components when i hit the page with any extension. like if i hit "/content/my-site/homepage.model.json" then it will give combined json of all the three components .There is a option to use infinity.json but t gives node structure as a json not a sling model & i don't want to use content fragments or i have  to develop a custom solution for this (using servlet and invoke it on the basis of selctor).

6 Replies

Avatar

Level 10

I have never tried this use case - i have asked some other internal ppl to look here.

Avatar

Employee Advisor

With the latest version of the Content Services feature pack hitting: "/content/my-site/homepage.model.json" as you described should give you a combined JSON of the Page + any components that have been added to the page. Are you not seeing this behavior? Or are you trying to do something else?

Avatar

Level 3

I tried it on AEM6.4 but didn't get expected rrsult. Can you please provide the latest package version

Avatar

Level 3

Hi dgordon86​, i tried that  but it giving me extra properties in json such like class etc.

below is json

{

   "designPath":"/libs/settings/wcm/designs/default",

   "title":"es",

   "lastModifiedDate":1537171015307,

   "templateName":"adminconfig",

   "language":"es",

   ":type":"AEMMaven123/components/structure/page",

   ":items":{

      "root":{

         "gridClassNames":"aem-Grid aem-Grid--12 aem-Grid--default--12",

         "columnCount":12,

         ":items":{

            "responsivegrid":{

               "gridClassNames":"aem-Grid aem-Grid--12 aem-Grid--default--12",

               "columnCount":12,

               ":items":{

                  "headerfooterconfig":{

                     ":type":"AEMMaven123/components/content/headerfooterconfig",

                     "logoRedirectPath":"/content/AEMMaven123/ca/es",

                     "mainlogoAltText":"aemmaven",

                     "fileReferenceMain":"/content/dam/aempractice/logo.png",

                     "columnClassNames":"aem-GridColumn aem-GridColumn--default--12"

                  }

               },

               ":itemsOrder":[

                  "headerfooterconfig"

               ],

               ":type":"wcm/foundation/components/responsivegrid",

               "columnClassNames":"aem-GridColumn aem-GridColumn--default--12"

            }

         },

         ":itemsOrder":[

            "responsivegrid"

         ],

         ":type":"wcm/foundation/components/responsivegrid"

      }

   },

   ":itemsOrder":[

      "root"

   ]

}

You can see there are many properties like itemsOrder,gridClassNames,columnClassNames. Apart from this i'm using @jsonignore annotation for "mainlogoAltText" in HeaderFooterConfig Model class still it's appearing here. where as if i call the resource directly using model selector this doesn't appear in end json.

Avatar

Employee Advisor

karansheel that is the expected behavior since when you call model.json at the Page level you will get the exported JSON from the Core Component Page: aem-core-wcm-components/PageImpl.java at master · Adobe-Marketing-Cloud/aem-core-wcm-components · Gi... and the JSON exported by the Responsive Grid Exporter: ResponsiveGridExporter ("The Adobe AEM Quickstart and Web Application.") 

If you want to override this JSON you will need to provide your own Sling Model for the Page component and your own Sling Model for the Responsive Grid. You might be able to use the Delegation Pattern for the Page Component: Delegation Pattern for Sling Models · Adobe-Marketing-Cloud/aem-core-wcm-components Wiki · GitHub  but for the ResponsiveGrid (since its not a Core Component) you will need to roll your own.

Avatar

Level 10

model is the selector used by page model sling exporter.

When you have custom implementation of component sling exporter, you have  to give the path to component in repository and then use model.json on it