CaaS for a page content in aem

Avatar

Avatar
Validate 10
Level 2
karansheel
Level 2

Likes

6 likes

Total Posts

39 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 10
Level 2
karansheel
Level 2

Likes

6 likes

Total Posts

39 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile
karansheel
Level 2

17-09-2018

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).

Replies

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

17-09-2018

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

Avatar

Avatar
Ignite 1
Employee
dgordon86
Employee

Likes

49 likes

Total Posts

73 posts

Correct reply

26 solutions
Top badges earned
Ignite 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile

Avatar
Ignite 1
Employee
dgordon86
Employee

Likes

49 likes

Total Posts

73 posts

Correct reply

26 solutions
Top badges earned
Ignite 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile
dgordon86
Employee

17-09-2018

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

Avatar
Validate 10
Level 2
karansheel
Level 2

Likes

6 likes

Total Posts

39 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 10
Level 2
karansheel
Level 2

Likes

6 likes

Total Posts

39 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile
karansheel
Level 2

17-09-2018

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

Avatar

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

277 likes

Total Posts

1,502 posts

Correct reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

277 likes

Total Posts

1,502 posts

Correct reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
edubey
Level 10

17-09-2018

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

Avatar

Avatar
Validate 10
Level 2
karansheel
Level 2

Likes

6 likes

Total Posts

39 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 10
Level 2
karansheel
Level 2

Likes

6 likes

Total Posts

39 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 1
View profile
karansheel
Level 2

17-09-2018

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

Avatar
Ignite 1
Employee
dgordon86
Employee

Likes

49 likes

Total Posts

73 posts

Correct reply

26 solutions
Top badges earned
Ignite 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile

Avatar
Ignite 1
Employee
dgordon86
Employee

Likes

49 likes

Total Posts

73 posts

Correct reply

26 solutions
Top badges earned
Ignite 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile
dgordon86
Employee

18-09-2018

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.