Communication Data Type
The communication data type is set an HTML element inside the AEM Page component using the data-cq-datatype
attribute. When the communication data type is set to JSON, the GET requests hit the Sling Model endpoints of a component. After an update occurs in the page editor, the JSON representation of the updated component is sent to the Page Model library. The Page Model library then warns the SPA of updates.
SPA Page Component - body.html
<div id="page"></div>
In addition to being good practice not to delay the DOM generation, the SPA framework requires the scripts to be added at the end of the body.
SPA Page Component -customfooterlibs.html
<sly data-sly-use.clientLib="${'/libs/granite/sightly/templates/clientlib.html'}"></sly>
<sly data-sly-test="${wcmmode.edit || wcmmode.preview}"
data-sly-call="${clientLib.js @ categories='cq.authoring.pagemodel.messaging'}"></sly>
<sly data-sly-call="${clientLib.js @ categories='we-retail-journal-react'}"></sly>
The meta resource properties that describe the SPA content:
SPA Page Component - customheaderlibs.html
<meta property="cq:datatype" data-sly-test="${wcmmode.edit || wcmmode.preview}" content="JSON"/>
<meta property="cq:wcmmode" data-sly-test="${wcmmode.edit}" content="edit"/>
<meta property="cq:wcmmode" data-sly-test="${wcmmode.preview}" content="preview"/>
<meta property="cq:pagemodel_root_url" data-sly-use.page="com.adobe.cq.sample.spa.journal.models.AppPage" content="${page.rootUrl}"/>
<sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html">
<sly data-sly-call="${clientlib.css @ categories='we-retail-journal-react'}"/>
</sly>
Meta Properties
-
cq:wcmmode
: WCM mode of the editors (for example, page, template) -
cq:pagemodel_root_url
: URL of the root model of the App. Crucial when directly accessing a child page since the child page model is a fragment of the app root model. The[PageModelManager](/docs/experience-manager-65/sites-developing/spa-page-component.md)
then systematically recomposes the application initial model as entering the application from its root entry point. -
cq:pagemodel_router
: Enable or disable the[ModelRouter](/docs/experience-manager-65/sites-developing/spa-routing.md)
of thePageModelManager
library -
cq:pagemodel_route_filters
: Comma separated list or regular expressions to provide routes the[ModelRouter](/docs/experience-manager-65/sites-developing/spa-routing.md)
must ignore.
Page Editor Overlay Synchronization
The synchronization of the overlays is guaranteed by the very same Mutation Observer provided by the cq.authoring.page
category.