Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!
SOLVED

Using the Granite include to include an individual item in a cq:dialog

Avatar

Level 3

We are currently on AEM 6.0, SP1 for what its worth.

I am setting up the cq:dialog's for each of my individual components.  I figured out how to use the granite/ui/components/foundation/include to include multiple elements inside a dialog.  After doing this, I thought about it some more and wondered if I can do the same thing to include a single granite component (a select with almost 40 options) in multiple dialogs.  The answer to that is it includes it OK, but it does not seem to save the results out to the content repository.  Based on the following code was wondering if anyone had any suggestions as to how to get it to save it's changes (again, for what it's worth, I make a change to the textbox that is inside the same tab and that does save any changes out to the repository). 

!Dummy (hidden) component solely setup to store these kind of selects <?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:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="nt:unstructured" jcr:title="Standard CQ Dialog" sling:resourceType="cq/gui/components/authoring/dialog"> <content jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container"> <layout jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/layouts/tabs" type="nav"/> <items jcr:primaryType="nt:unstructured"> <icon jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/select" > <items jcr:primaryType="nt:unstructured"> <option LOTS OF THEM /> </items> </icon> </items> </content> </jcr:root>

Attempting to include the above select:

<callToActionIcon jcr:primaryType="nt:unstructured" fieldLabel="Icon" sling:resourceType="granite/ui/components/foundation/include" name="./callToActionIcon" path="/apps/global-web/components/content/standardCQDialog/cq:dialog/content/items/icon" resourceType="granite/ui/components/foundation/form/select" />

Thanks in advance!

1 Accepted Solution

Avatar

Correct answer by
Level 10

One of our Touch UI experts said: 

Set the name on included widget 

 

                <items jcr:primaryType="nt:unstructured">

                            <icon

                                jcr:primaryType="nt:unstructured"

                                name="./callToActionIcon"

                              sling:resourceType="granite/ui/components/foundation/form/select">

                                <items jcr:primaryType="nt:unstructured">

                                    <option LOTS OF THEM />

                                </items>

                            </icon>

                        </items>

View solution in original post

4 Replies

Avatar

Level 10

"if I can do the same thing to include a single granite component (a select with almost 40 options) in multiple dialogs."

To build TOuch UI dialog- you add includes as specified in this article: 

https://helpx.adobe.com/experience-manager/using/creating-touchui-component.html

Avatar

Level 3

I appreciate the attempt.  What I am attempting to do is to NOT have to copy and paste the same 40 item select into multiple dialogs.  Since I figured out how to include a whole tabs worth of items using the granite/ui/components/foundation/include I wanted to try and use the include to include a single item in a dialog.  It works, as I have it referenced above in that it pulls in the whole list of items, but changing the selection and saving does not change the value.  So the question is if there is anything that I can change and be able to reuse the select list? 

I felt that since this select list would not be changing that often (once a year, if that often) that this was probably the preferred method vs. pulling from a servlet. 

Thanks for your consideration.

Avatar

Correct answer by
Level 10

One of our Touch UI experts said: 

Set the name on included widget 

 

                <items jcr:primaryType="nt:unstructured">

                            <icon

                                jcr:primaryType="nt:unstructured"

                                name="./callToActionIcon"

                              sling:resourceType="granite/ui/components/foundation/form/select">

                                <items jcr:primaryType="nt:unstructured">

                                    <option LOTS OF THEM />

                                </items>

                            </icon>

                        </items>

Avatar

Level 3

Yes.  That works better.  Based on how it is working now from that change, what happens if I want to use that item across multiple dialogs but it is currently named differently, is there a way to override the name "locally" in the dialog?  Thanks.