Leiste mit Community-Erfolgen erweitern.

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

Mark Solution

Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.

GELÖST

AEM 6.4 Model @Exporter for pages

Avatar

Level 2
Hello everyone,
im trying to export my model with @exporter.Somehow is not working and i guess it cold be because resourcetype.My model is for "pageanalytics" so the resourcetype should be something like:myapps/components/structure/pagebecause my model is called in head.html which is in page.If i remove the resorucetype the model is working but its not exported.if i put that path, its a null point and mypage.model.json is blank and not loadedWhat im doin wrong?
@Model(
        adaptables = SlingHttpServletRequest.class,
        adapters = ComponentExporter.class,
        defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL,
        resourceType = "myapp/components/structure/page")
@Exporter(
        name = ExporterConstants.SLING_MODEL_EXPORTER_NAME,
        extensions = ExporterConstants.SLING_MODEL_EXTENSION)
1 Akzeptierte Lösung

Avatar

Korrekte Antwort von
Community Advisor

Hi,

You need to do like

 

@Model(adaptables = SlingHttpServletRequest.class, adapters = {MyModel.class, ContainerExporter.class}, resourceType ="myapp/components/structure/page") 
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
Arun Patidar

AEM LinksLinkedIn

Lösung in ursprünglichem Beitrag anzeigen

4 Antworten

Avatar

Community Advisor

Can you try something like

 

@Model(adaptables = SlingHttpServletRequest.class, adapters = {Page.class, ContainerExporter.class}, resourceType = PageImpl.RESOURCE_TYPE)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)

https://github.com/adobe/aem-core-wcm-components/blob/e49999b3733ceb487fd40774ac4a15f921713336/bundl... 

Arun Patidar

AEM LinksLinkedIn

Avatar

Level 2

Hello, thank you for your answer.

Somehow i cannot do 

resourceType = PageImpl.RESOURCE_TYPE

Because my IDE doesnt recognize it.

public class MyModel extends ModelJsonExporter implements ComponentExporter{

 Could be because my model definition?

Avatar

Korrekte Antwort von
Community Advisor

Hi,

You need to do like

 

@Model(adaptables = SlingHttpServletRequest.class, adapters = {MyModel.class, ContainerExporter.class}, resourceType ="myapp/components/structure/page") 
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
Arun Patidar

AEM LinksLinkedIn

Avatar

Level 2

Yes this is the way, it was not working for some other issue.

Thanks a lot!