How to have shared cq_dialog | Community
Skip to main content
Level 2
June 26, 2025
Solved

How to have shared cq_dialog

  • June 26, 2025
  • 3 replies
  • 565 views
Consider I have 2 components (both of them footer section) cq_dialog of footer has 3 fields 1) Title 2) Content 3) Image How do I share the cq_dialog between my 2 components. Is there any other way than direct copy pasting stuff
Best answer by konstantyn_diachenko

Hi @kunalna1 ,

 

I would suggest to reuse tabs or containers of the dialog and include them via special resource type. See details below.

 

Firstly, you have to extract your reusable configuration to a separate place like: /apps/project/components/authoring/dialog/footer.

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" jcr:primaryType="nt:unstructured"> <tab_configuration jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container"> <items jcr:primaryType="nt:unstructured"> </items> </tab_configuration> </jcr:root>

Secondly, you have to include extracted piece of configuration by using sling:resourceType="granite/ui/components/coral/foundation/include".

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" jcr:primaryType="nt:unstructured" jcr:title="Footer" sling:resourceType="cq/gui/components/authoring/dialog"> <content jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container"> <items jcr:primaryType="nt:unstructured"> <tabs jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/tabs" maximized="{Boolean}true"> <items jcr:primaryType="nt:unstructured"> <configurationtab jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/include" path="/mnt/overlay/project/components/authoring/dialog/footer/tab_configuration"/> </items> </tabs> </items> </content> </jcr:root>

 

3 replies

Suraj_Kamdi
Community Advisor
Community Advisor
June 26, 2025

Just use sling:resourceSuperType=<component path which has cq:dialog> on other component property.

konstantyn_diachenko
Community Advisor
konstantyn_diachenkoCommunity AdvisorAccepted solution
Community Advisor
June 26, 2025

Hi @kunalna1 ,

 

I would suggest to reuse tabs or containers of the dialog and include them via special resource type. See details below.

 

Firstly, you have to extract your reusable configuration to a separate place like: /apps/project/components/authoring/dialog/footer.

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" jcr:primaryType="nt:unstructured"> <tab_configuration jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container"> <items jcr:primaryType="nt:unstructured"> </items> </tab_configuration> </jcr:root>

Secondly, you have to include extracted piece of configuration by using sling:resourceType="granite/ui/components/coral/foundation/include".

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:granite="http://www.adobe.com/jcr/granite/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" jcr:primaryType="nt:unstructured" jcr:title="Footer" sling:resourceType="cq/gui/components/authoring/dialog"> <content jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container"> <items jcr:primaryType="nt:unstructured"> <tabs jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/tabs" maximized="{Boolean}true"> <items jcr:primaryType="nt:unstructured"> <configurationtab jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/include" path="/mnt/overlay/project/components/authoring/dialog/footer/tab_configuration"/> </items> </tabs> </items> </content> </jcr:root>

 

Kostiantyn Diachenko, Community Advisor, Certified Senior AEM Developer, creator of free AEM VLT Tool, maintainer of AEM Tools plugin.
Vishal_Anand
Level 4
June 26, 2025

Adobe recommends modular development with emphasis on reusability. You can create multiple components by leveraging same cq:dialog using their sling resourceType and resourceSuperType. You can read more about it over here: https://forums.adobe.com/external-link.jspa?url=http%3A%2F%2Fwem.help.adobe.com%2Fenterprise%2Fen_US%2F10-0%2Fwem%2Fdeveloping%2Fthe_basics.html

 

These super types are also considered when trying to find a script (especially for handling dialog validations). The advantage of resource super types is that they may form a hierarchy of resources where the default resource type sling/servlet/default (used by the default servlets) is effectively the root.

Also - see the SLing docs. This is a good topic to start with:

https://sling.apache.org/documentation/the-sling-engine/url-to-script-resolution.html