How to create reusable dialog.xml

Introduction

The cqinclude xtype allows you to create a dialog.xml heritates of another one. In example, we have a button dialog which is include in parrent dialog. But you face a problem when multiple properties have the same name. In my previous example, both the button and parrent dialog have a label property. In that case, label properties will be saved under the same property.

ACS AEM COMMONS provides an elegant solution to the previous problem : CQInclude Namespace.

How to use

First of all, you need to have the acs aem commons package installed (CQInclude Namespace is available since version 1.10.2).

You need to create a cq:widgetCollectionNode. In example, you can create a directory apps/myapp/components/defaults/button. Create the following files in the directory :

In the parrent dialog, you can import the previous dialog like this :

The button properties will not be save in the parrent node properties. The cqinclude.namespace creates a second node (button1) under the parrent node. The button1 node contains all the included properties. If you change the ‘button1’ to ‘button2’, it will creates another node. You can also include multiple dialogs (or mutiple times the same dialog) under differents names.

Leave a Reply