Skip to main content
Level 3
Sep 29, 2016 11:53 AM UTC
Solved

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

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
squid267Accepted solution
Level 3
Sep 30, 2016 12:50 PM UTC

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. 

4 replies

smacdonald2008
Level 10
Sep 29, 2016 2:22 PM UTC

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

Translate
squid267Author
Level 3
Sep 29, 2016 4:03 PM UTC

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

Translate
smacdonald2008
Level 10
Sep 29, 2016 4:47 PM UTC

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. 

Translate
squid267AuthorAccepted solution
Level 3
Sep 30, 2016 12:50 PM UTC

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. 

Translate