Sling model Delegate in SPA project | Community
Skip to main content
Level 2
May 28, 2024
Solved

Sling model Delegate in SPA project

  • May 28, 2024
  • 1 reply
  • 816 views

A sling model delegate was added for page and XF components similar to as in the example given in this blog - https://levelup.gitconnected.com/aem-extend-core-component-models-using-resource-type-association-and-delegation-b8855ed281e2

 

Now while including an SPA Project to the same AEM instance, SPA Page model delegate in turn delegates to Page core component as in link. Though the resource type is different, earlier mentioned sling model delegate for page is always invoked by SPA Page model. Anyone faced such a scenario, pls guide.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by TarunKumar

Hi @ramya726 ,

The resolution and the management of the page model is delegated to a provided PageModel library. The SPA must use the Page Model library to be initialized and be authored by the SPA Editor. The Page Model library provided indirectly to the AEM Page component via the aem-react-editable-component npm. The Page Model is an interpreter between AEM and the SPA and therefore always must be present. When the page is authored, an additional library cq.authoring.pagemodel.messaging must be added to enable the communication with the page editor.


For more details on it you can check below link
https://experienceleague.adobe.com/en/docs/experience-manager-65/content/implementing/developing/spas/spa-overview


Thanks
Tarun

1 reply

TarunKumar
Community Advisor
TarunKumarCommunity AdvisorAccepted solution
Community Advisor
June 14, 2024

Hi @ramya726 ,

The resolution and the management of the page model is delegated to a provided PageModel library. The SPA must use the Page Model library to be initialized and be authored by the SPA Editor. The Page Model library provided indirectly to the AEM Page component via the aem-react-editable-component npm. The Page Model is an interpreter between AEM and the SPA and therefore always must be present. When the page is authored, an additional library cq.authoring.pagemodel.messaging must be added to enable the communication with the page editor.


For more details on it you can check below link
https://experienceleague.adobe.com/en/docs/experience-manager-65/content/implementing/developing/spas/spa-overview


Thanks
Tarun

ramya726Author
Level 2
July 8, 2024

Thanks @tarunkumar . Have gone through the above suggestion, but still couldn't resolve the issue. Please find further details on the issue below,

 

(Non SPA project component)Existing Sling delegated Model resource type: wknd/components/experiencefragment

 

Now while including an SPA Project structure to the same AEM instance, We're facing an issue when we load a SPA page which contains experiencefragment component configured in template. 
SPA page invokes sling model where @Delegate annotation returns NULL which then results in model.json failure.

 

Ideally sling model should not be invoked while loading SPA page because the resourceType of experiencefragment component(wknd-spa-react/components/experiencefragment) used in SPA page is different from what we implemented in sling model.