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.
SOLVED

How to get component path in component dialog.

Avatar

Community Advisor

Hi,

I've requirement where I need to populate component path in the component's dialog. For example, I've a component called 'Hello' and page 'XYZ'. I'm dropping the component into the page parsys. Then component path would be something: /content/XYZ/jcr:content/parsys/Hello

Now, when I edit the component 'Hello', I need to get path (/content/XYZ/jcr:content/parsys/Hello) in the dialog listener. Quick response would be appreciated.

 

Thanks In Advance

1 Accepted Solution

Avatar

Correct answer by
Employee

This is available as the path property on the dialog component: http://dev.day.com/docs/en/cq/current/widgets-api/?class=CQ.Dialog

View solution in original post

6 Replies

Avatar

Level 10

Use a Sling call to get the current path and then write a custom xtype with JavaScript. Populate a JS variable with the current path and assign the variable to a control in the custom xpath control.  

Avatar

Correct answer by
Employee

This is available as the path property on the dialog component: http://dev.day.com/docs/en/cq/current/widgets-api/?class=CQ.Dialog

Avatar

Level 2

justin_at_adobe wrote...

This is available as the path property on the dialog component: http://dev.day.com/docs/en/cq/current/widgets-api/?class=CQ.Dialog

 

I was just trying this myself, so thought I would share the code based on Justin's suggestion above:

<listeners jcr:primaryType="nt:unstructured" activate="function(c) {console.log('this.path = '+this.path);}"/>

Avatar

Community Advisor

Thanks for  your replies, 
G.W, I tried your approach, but I'm getting obj.path as undefined. Here is sample dialog code: Actually, I need component path information at field levels inside the dialog tab. When I add the listener at dialog level I"m able to get the path but not at field levels.  Please let me know If I'm doing something wrong here:

<jcr:root 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="cq:Dialog"
    title="dialog"
    xtype="dialog">
    <items
        jcr:primaryType="cq:Widget"
        xtype="tabpanel">
        <items jcr:primaryType="cq:WidgetCollection">
            <tab1
                jcr:primaryType="cq:Panel"
                title="Title">
                <items jcr:primaryType="cq:WidgetCollection">
                    <title
                        jcr:primaryType="cq:Widget"
                        fieldLabel="Title"
                        name="./value"
                        xtype="textfield"/> 

                       <listeners

                                jcr:primaryType="nt:unstructured"
                                activate="function(x){alert("this.path:"+this.path.toString());}"/>                  
                </items>
               
            </tab1>
        </items>
    </items>

</jcr:root>

Avatar

Community Advisor

Finally, I could make this to work..

Thanks for your inputs.