Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Listeners

Avatar

Level 4

Hi Team,

Am trying to set random value for textfield in our scenario.

but it's not setting up.

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

    jcr:primaryType="cq:Dialog"

    title="Multi Field"

    xtype="dialog">

    <items

        jcr:primaryType="cq:Widget"

        xtype="tabpanel">

        <items jcr:primaryType="cq:WidgetCollection">

            <tab1

                jcr:primaryType="cq:Panel"

                id="first"

                title="Global Disclosure">

                <items jcr:primaryType="cq:WidgetCollection">

                    <example

                        jcr:primaryType="cq:Widget"

                        hideLabel="false"

                        name=“./example”

                        id="global"

                        title=“Id”

                        xtype="multifield">

                        <fieldConfig

                            jcr:primaryType="cq:Widget"

                            border="true"

                            hideLabel="true"

                            layout="form"

                            padding="10px"

                            width="1000"

                            id="multi"

                            xtype="multi-field-panel">

                            <items jcr:primaryType="cq:WidgetCollection">

                                <Id

                                    jcr:primaryType="cq:Widget"

                                    dName=“id"

                                    fieldLabel="Id"

                                    width="300"

                                    maxLength="10"

                                    id=“id"

                                    xtype="textfield">

                                     <listeners jcr:primaryType="nt:unstructured" 

                                          loadcontent="function(box,value){myValue = Math.random() * 10;

                                          value = box.findParenteByType('tabpanel').getComponent('first').getComponent('global').getComponent('multi').getComponent(‘id');

                                          value.setValue('Set'+myValue);

                                          }"/>

                                          </Id>

                          

                            </items>

                        </fieldConfig>

                    </example>

                </items>

            </tab1>

</items>

</items>

</jcr:root>

 

Please guild me, if i miss something in my dialog.

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Write a custom xtype and set it using JS and available listeners in the Widget API.

http://docs.adobe.com/docs/en/cq/5-6-1/widgets-api/index.html

See this community article on how to dynamically set dialog fields:

https://helpx.adobe.com/experience-manager/using/dynamically-updating-aem-custom-xtype.html

Coding with the widget API in a JS (custom xtype) gives you much more control as opposed to trying to get a method that you define in a node property working. In an Event handler of the the custom xtype - create the random value and set it within the text field.  

View solution in original post

3 Replies

Avatar

Level 10

Is your loadcontent listener is getting called ?. try adding a console statement and verify this.

Avatar

Correct answer by
Level 10

Write a custom xtype and set it using JS and available listeners in the Widget API.

http://docs.adobe.com/docs/en/cq/5-6-1/widgets-api/index.html

See this community article on how to dynamically set dialog fields:

https://helpx.adobe.com/experience-manager/using/dynamically-updating-aem-custom-xtype.html

Coding with the widget API in a JS (custom xtype) gives you much more control as opposed to trying to get a method that you define in a node property working. In an Event handler of the the custom xtype - create the random value and set it within the text field.  

Avatar

Level 4

edubey wrote...

Is your loadcontent listener is getting called ?. try adding a console statement and verify this.

 

loadcontent is not working, i can't see anything in console.