Javascript Use API How To Get Property/Content From Other Component in Sampe Page | Community
Skip to main content
August 4, 2017
Solved

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

  • August 4, 2017
  • 3 replies
  • 4177 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

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 class

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.

3 replies

viveksachdeva
Community Advisor
Community Advisor
August 4, 2017

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

smacdonald2008
smacdonald2008Accepted solution
August 4, 2017

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 class

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.

smacdonald2008
August 4, 2017