Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Fields not being populated in dialog when using multifield

Avatar

Level 2

Hello. I am having an issue when creating a new component in AEM 6.4.5 using a multifield in the dialog. The values are saved in the node, but when entering the dialog again these values are not displayed, meaning that when changing anything in the component we would have to reauthor all of the values again. I have found some solutions following the old style of creating child nodes with the individual values, and this populates the dialog properly. I am however of the understanding that with newer versions of AEM this is no longer the recommended way of working.

The dialog for our component has 2-6 columns to be authored and the number of tabs/columns to be shown is chosen in the "General Settings" tab.

This is what the XML for the dialog currently looks like. I have for simplicity removed all columns but one as they are all identical:

<?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"

    sling:resourceType="cq/gui/components/authoring/dialog"

    helpPath="http://www.adobe.com/go/aem6_1_docs_component_en">

    <content

        jcr:primaryType="nt:unstructured"

        sling:resourceType="granite/ui/components/foundation/container"

        class="target-options-dialog-footer"

        formName="extendedFooter"

        onloadFunc="function(){extendedFooterOnLoad();}">

        <layout

            jcr:primaryType="nt:unstructured"

            sling:resourceType="granite/ui/components/foundation/layouts/tabs"

            type="nav"/>

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

            <general-settings

                jcr:primaryType="nt:unstructured"

                jcr:title="General Settings"

                sling:resourceType="granite/ui/components/foundation/container">

                <layout

                    jcr:primaryType="nt:unstructured"

                    sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/>

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

                    <columns

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/foundation/container">

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

                            <number-of-items

                                jcr:primaryType="nt:unstructured"

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

                                fieldLabel="Select number of columns"

                                id="columnNumber"

                                name="./columnNumber"

                                onSelectFunc="function(){extendedFooterOnSelect();}"

                                value="2&#xa;">

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

                                    <two

                                        jcr:primaryType="nt:unstructured"

                                        text="2 Columns"

                                        value="2"/>

                                    <three

                                        jcr:primaryType="nt:unstructured"

                                        text="3 Columns"

                                        value="3"/>

                                    <four

                                        jcr:primaryType="nt:unstructured"

                                        text="4 Columns"

                                        value="4"/>

                                    <five

                                        jcr:primaryType="nt:unstructured"

                                        text="5 Columns"

                                        value="5"/>

                                    <six

                                        jcr:primaryType="nt:unstructured"

                                        text="6 Columns"

                                        value="6"/>

                                </items>

                            </number-of-items>

                        </items>

                    </columns>

                </items>

            </general-settings>

            <column-one

                jcr:primaryType="nt:unstructured"

                jcr:title="Column One"

                sling:resourceType="granite/ui/components/foundation/container"

                id="1">

                <layout

                    jcr:primaryType="nt:unstructured"

                    sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/>

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

                    <columns

                        jcr:primaryType="nt:unstructured"

                        sling:resourceType="granite/ui/components/foundation/container">

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

                            <column-title

                                jcr:primaryType="nt:unstructured"

                                sling:resourceType="granite/ui/components/foundation/form/textfield"

                                fieldDescription="Please enter a column name"

                                fieldLabel="Column Label"

                                name="./titleColumn1"/>

                            <column-items

                                jcr:primaryType="nt:unstructured"

                                sling:resourceType="granite/ui/components/foundation/form/multifield"

                                fieldDescription="Click '+' to add a new item"

                                fieldLabel="Links">

                                <field

                                    jcr:primaryType="nt:unstructured"

                                    sling:resourceType="granite/ui/components/foundation/form/fieldset"

                                    name="./extendedFooterLinks">

                                    <layout

                                        jcr:primaryType="nt:unstructured"

                                        sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"

                                        method="absolute"/>

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

                                        <column

                                            jcr:primaryType="nt:unstructured"

                                            sling:resourceType="granite/ui/components/foundation/container">

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

                                                <text

                                                    jcr:primaryType="nt:unstructured"

                                                    sling:resourceType="granite/ui/components/foundation/form/textfield"

                                                    fieldLabel="Link Text *"

                                                    name="./linkTextColumn1"

                                                    required="{Boolean}true"/>

                                                <url

                                                    jcr:primaryType="nt:unstructured"

                                                    sling:resourceType="granite/ui/components/foundation/form/pathbrowser"

                                                    fieldLabel="URL *"

                                                    name="./linkUrlColumn1"

                                                    required="{Boolean}true"

                                                    rootPath="/content/scanianoe"/>

                                            </items>

                                        </column>

                                    </items>

                                </field>

                            </column-items>

                        </items>

                    </columns>

                </items>

            </column-one>

        </items>

    </content>

</jcr:root>

My question is then what in here is missing or wrong in the structure that makes it so that when opening the dialog, previously saved values will be shown?

5 Replies

Avatar

Employee

You may want ot check the following sample project and compare the structure with what you have and make sure Coral components have been used properly.
Creating a Granite/Coral 6.3 Multifield HTL component for Adobe Experience Manager

Avatar

Level 2

So the answers is that I am mistaken in that data should not be stored in child nodes?

Avatar

Community Advisor

Hi,

You should use Granite/Coral3 resourcetype instaedof Coral2

Multifield — Granite UI 1.0 documentation

and you need to add

composite(Boolean)= true

property in multifield.

The data will be stored as node.



Arun Patidar

Avatar

Level 2

So saving the data in child nodes is the recommended way of working?

Avatar

Community Advisor

Yes with Granite 3, but with Coral2 you can save as json also with the help of acs-common.

I did not see any issue using Granite3 with the node data store.

With Sling Model, it is very easy to adapt node to class and get values using getter, instead of parsing json with JSON_STORE.



Arun Patidar