Expand my Community achievements bar.

SOLVED

Javascript Use API How To Get Property/Content From Other Component in Sampe Page

Avatar

Level 1

Dear Good People,

I am new in using AEM(Adobe Experience Manager)

I have a page that contains 2 or more components in a responsivegrid(wcm/foundation/components/responsivegrid) component area.

For example component date_event period that contains only 2 nodes which are :

- node start date (datepicker)

- node end date (datepicker)

in the file date_event.js within in component date_event, i retrieve those both nodes and return it.

then I have other component that want to retrieve node start date & end date from date_event component, but i got stuck while working on it.

So i need help how to figure it out?

1 Accepted Solution

Avatar

Correct answer by
Level 10

From my understanding - you have a separate HTL component and you want it to retrieve the value of a data component on another page.

If this is the case - you will have much more control using Java API to read node properties and using WCMUSePOJO as opposed to JS USE.

See this article - Scott's Digital Community: Creating an AEM HTML Template Language component that uses the WCMUsePojo...

It will teach you how to use the Java side of a HTL component. Then you can use Java APIs to read node props on a page.

View solution in original post

3 Replies

Avatar

Community Advisor

You need to locate the first resource and then iterate over its properties... So, from component 2, you should get its parent..something like resource.getParent()... this is common parent for both your components... then do parentComponent.getChild(<first component path>). Now that you have it, you can read values from it...

Avatar

Correct answer by
Level 10

From my understanding - you have a separate HTL component and you want it to retrieve the value of a data component on another page.

If this is the case - you will have much more control using Java API to read node properties and using WCMUSePOJO as opposed to JS USE.

See this article - Scott's Digital Community: Creating an AEM HTML Template Language component that uses the WCMUsePojo...

It will teach you how to use the Java side of a HTL component. Then you can use Java APIs to read node props on a page.