Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Adding, editing, deleting component doesn't refresh page even with cq listener configured

Avatar

Level 4

This one has me scratching my head. I created a component and dragged on to a page I created with a basic template. It doesn't refresh the page even though I've set aftercreate,afterdelete,afteredit,afterinsert and aftermove to REFRESH_PAGE. Here is my _cq_editConfig.xml file.

 

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" cq:actions="[edit,delete,insert,copymove]" cq:inherit="true" jcr:primaryType="cq:EditConfig"> <cq:listeners jcr:primaryType="cq:EditListenersConfig" aftercreate="REFRESH_PAGE" afterdelete="REFRESH_PAGE" afteredit="REFRESH_PAGE" afterinsert="REFRESH_PAGE" afterMove="REFRESH_PAGE"/> </jcr:root>

Then I tried dragging a we retail component that I know refreshes the page (in the we retail project) and it still didn't work. This leads me to think there is something wrong with my template or the page component it is inheriting from.

 

/templates/blank-template/.content.xml

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:description="Blank Template" jcr:mixinTypes="[mix:lockable]" jcr:primaryType="cq:Template" jcr:title="Blank Template" allowedPaths="[.*]" ranking="{Long}42"> <jcr:content jcr:primaryType="cq:PageContent" sling:resourceType="my-app/components/structure/page"> </jcr:content> </jcr:root>

/components/structure/page/.content.xml

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Component" jcr:title="A Page" sling:resourceSuperType="wcm/foundation/components/page" componentGroup=".hidden"/>

 

Any help would be greatly appreciated it.

1 Accepted Solution

Avatar

Correct answer by
Level 4

So I figured it out. I used we-retail's page component as a base.

So page.html references headlibs.html which references author.html

author.html

<sly data-sly-use.wcmInit="initwcm.js" data-sly-use.clientLib="${'/libs/granite/sightly/templates/clientlib.html'}" data-sly-test="${!wcmInit.wcmmode.disabled && wcmInit.isTouchAuthoring}" data-sly-call="${clientLib.all @ categories='cq.authoring.page'}" /> <sly data-sly-test="${!wcmInit.wcmmode.disabled && !wcmInit.isTouchAuthoring}" data-sly-call="${clientLib.all @ categories='cq.wcm.edit'}" /> <script data-sly-test="${!wcmInit.wcmmode.disabled && !wcmInit.isTouchAuthoring}" type="text/javascript"> (function() { var cfg = ${wcmInit.undoConfig @ context='unsafe'}; cfg.pagePath = "${currentPage.path @ context='uri'}"; if (CQClientLibraryManager.channelCB() != "touch") { cfg.enabled = ${wcmInit.wcmmode.edit @ context="scriptString"}; CQ.undo.UndoManager.initialize(cfg); CQ.Ext.onReady(function() { CQ.undo.UndoManager.detectCachedPage((new Date()).getTime()); }); } })(); CQ.WCM.launchSidekick("${currentPage.path @ context='uri'}", { propsDialog: "${wcmInit.dialogPath @ context='uri'}", locked: ${currentPage.locked @ context="scriptString"} }); </script> <!--/* WCM initialization code end */--> <sly data-sly-test="${!wcmInit.wcmmode.disabled}" data-sly-call="${clientLib.all @ categories='cq.wcm.foundation-main'}" /> <!--/* Temporary fix for missing CQ.shared on some pages */--> <sly data-sly-test="${!wcmInit.wcmmode.disabled && wcmInit.isTouchAuthoring}" data-sly-call="${clientLib.all @ categories='cq.shared'}" />

What's really important is here 

<sly data-sly-use.wcmInit="initwcm.js" data-sly-use.clientLib="${'/libs/granite/sightly/templates/clientlib.html'}" data-sly-test="${!wcmInit.wcmmode.disabled && wcmInit.isTouchAuthoring}" data-sly-call="${clientLib.all @ categories='cq.authoring.page'}" />

That must load in some script for intlaizing the sidekick in classic, and firing up other parts of the author environment. 

View solution in original post

4 Replies

Avatar

Level 10

Have you tested this with other pages? Does it work in other pages?

Avatar

Level 4

My component correct refreshes when I add to any page in We-Retail. Which helps cement its an issue with my template/page component. Good suggestion! Now to figure out why. smiley

Avatar

Level 10

Try in the Geo apps too to see if there is an issue there as well. Many times in AEM - finding issues - it helps to see if it works in other locations. 

Avatar

Correct answer by
Level 4

So I figured it out. I used we-retail's page component as a base.

So page.html references headlibs.html which references author.html

author.html

<sly data-sly-use.wcmInit="initwcm.js" data-sly-use.clientLib="${'/libs/granite/sightly/templates/clientlib.html'}" data-sly-test="${!wcmInit.wcmmode.disabled && wcmInit.isTouchAuthoring}" data-sly-call="${clientLib.all @ categories='cq.authoring.page'}" /> <sly data-sly-test="${!wcmInit.wcmmode.disabled && !wcmInit.isTouchAuthoring}" data-sly-call="${clientLib.all @ categories='cq.wcm.edit'}" /> <script data-sly-test="${!wcmInit.wcmmode.disabled && !wcmInit.isTouchAuthoring}" type="text/javascript"> (function() { var cfg = ${wcmInit.undoConfig @ context='unsafe'}; cfg.pagePath = "${currentPage.path @ context='uri'}"; if (CQClientLibraryManager.channelCB() != "touch") { cfg.enabled = ${wcmInit.wcmmode.edit @ context="scriptString"}; CQ.undo.UndoManager.initialize(cfg); CQ.Ext.onReady(function() { CQ.undo.UndoManager.detectCachedPage((new Date()).getTime()); }); } })(); CQ.WCM.launchSidekick("${currentPage.path @ context='uri'}", { propsDialog: "${wcmInit.dialogPath @ context='uri'}", locked: ${currentPage.locked @ context="scriptString"} }); </script> <!--/* WCM initialization code end */--> <sly data-sly-test="${!wcmInit.wcmmode.disabled}" data-sly-call="${clientLib.all @ categories='cq.wcm.foundation-main'}" /> <!--/* Temporary fix for missing CQ.shared on some pages */--> <sly data-sly-test="${!wcmInit.wcmmode.disabled && wcmInit.isTouchAuthoring}" data-sly-call="${clientLib.all @ categories='cq.shared'}" />

What's really important is here 

<sly data-sly-use.wcmInit="initwcm.js" data-sly-use.clientLib="${'/libs/granite/sightly/templates/clientlib.html'}" data-sly-test="${!wcmInit.wcmmode.disabled && wcmInit.isTouchAuthoring}" data-sly-call="${clientLib.all @ categories='cq.authoring.page'}" />

That must load in some script for intlaizing the sidekick in classic, and firing up other parts of the author environment.