내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

register sling model exporter at cq:Page with custom selector

Avatar

Level 3

We are currently working with a headless approach and I'm trying to estimate pros & cons of having more selectors in addition to 'model' at the cq:Page component. After digging through the request log and basically discovering what @Jörg_Hoh  also mentioned here: https://cqdump.wordpress.com/2019/01/07/how-does-sling-resolve-an-aem-page-to-the-correct-resource-t...  some special magic included within the cq:Page component redirects requests with special selector 'model' to the page-content where the sling-model-exporter ist registered.

It is easily possible to register sling-model-exporters to component-nodes if they have a proper sling:resourceType set but would it make sense to have this option on the page level too? Any dispatcher or security related issues maybe?

 

for instance

 

/content/somepage.model.json works

/content/somepage/jcr:content.customselector.json works

/content/somepage.customselector.json doesn't ?

 

 

주제

토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Employee Advisor

Hi Christoph,

If I understand you correctly, you would just start registering customer exporters as selectors selectors to the cq/Page resourcetype.

Technically I don't see a problem with that, but just be aware, that I can execute this exporter on pages where it shouldn't work. That means you need to write some code to ensure that this exporter is just executed on the right "type" of page, and not on any page. If you register that SME directly to the correct resource type, Sling does that for you.

원본 게시물의 솔루션 보기

6 답변 개

Avatar

정확한 답변 작성자:
Employee Advisor

Hi Christoph,

If I understand you correctly, you would just start registering customer exporters as selectors selectors to the cq/Page resourcetype.

Technically I don't see a problem with that, but just be aware, that I can execute this exporter on pages where it shouldn't work. That means you need to write some code to ensure that this exporter is just executed on the right "type" of page, and not on any page. If you register that SME directly to the correct resource type, Sling does that for you.

Avatar

Level 3
But a model is tied to a specific resourcetype?! The 'model' selector only forwards the request to the sling-model if there is a model registered at the resourcetype of the pages content-resource.

Avatar

Employee Advisor
You left me confused with your statement

Avatar

Community Advisor

Hi,

sling models work for page as well, if you do like /content/weretails/en.model.json

 

But if you looking for something custom, then it should be validated in terms of performance and error handling.

I tried to created similar just for fun - https://aemlab.blogspot.com/2019/07/get-json-response-of-aem-page.html

 

Arun Patidar

AEM LinksLinkedIn

Avatar

Level 3
This is not using the sling-model-exporter framework at all. And worse: It responds to all cq:Pages i.e. default-get-servlet and not only to specific page-resourcetypes!

Avatar

Community Advisor

Hi @cwalter 

This is true, the blog is created just for concept but it is not production ready.

The servlet can be changed to register for as page resource type(s).

The model selector used the sling model exporter, which will get executed if component model is using sling model exporters.But if you don't want to re-register everything then a servlet can be created to parse all node and return as json.

 

but if you want to implement the logic of model selector then you can look for the model.jsp at /libs/cq/Page/model.json.jsp

 

 

 

Arun Patidar

AEM LinksLinkedIn