Expand my Community achievements bar.

Join us in celebrating the outstanding achievement of our AEM Community Member of the Year!
SOLVED

how to access property in another section of my AEM page?

Avatar

Level 9

I have a property (hideBreadcrumb) that's been declared in ui.apps/src/main/content/jcr_root/apps/berkeley/components/page/base-page/basic-tab/.content.xml

I have a header.html that's located in ui.apps/src/main/content/jcr_root/apps/berkeley/components/page/base-page. Inside this html file, I can access the value for hideBreadcrumb.

If I try to access hideBreadcrumb from another section of my page (example: ui.apps/src/main/content/jcr_root/apps/berkeley/components/navigation-section/navigation-section.html), it's not working.

Any ideas on how it can be done? Thanks

1 Accepted Solution

Avatar

Correct answer by
Administrator

Please have a look at this thread:- How do I get the value of a property given an absolute path?

//You use the JCR API to get node prop values. See this article to learn how to work with AEM and the JCR API: Adobe Experience Manager Help | Programmatically Accessing Adobe Experience Manager Content using th...

Also,

See How to access component properties from a Java Class

// I would say from to use as much as you can the ValueMap-approach.

Page page = currentPage;

ValueMap props = page.getContentResource("componentName").adaptTo(ValueMap.class);

String title = props.get("jcr:title", "default value");

And

This Read out and use node parameters from other components via JS Use API



Kautuk Sahni

View solution in original post

3 Replies

Avatar

Correct answer by
Administrator

Please have a look at this thread:- How do I get the value of a property given an absolute path?

//You use the JCR API to get node prop values. See this article to learn how to work with AEM and the JCR API: Adobe Experience Manager Help | Programmatically Accessing Adobe Experience Manager Content using th...

Also,

See How to access component properties from a Java Class

// I would say from to use as much as you can the ValueMap-approach.

Page page = currentPage;

ValueMap props = page.getContentResource("componentName").adaptTo(ValueMap.class);

String title = props.get("jcr:title", "default value");

And

This Read out and use node parameters from other components via JS Use API



Kautuk Sahni

Avatar

Level 10

As long as you know the relative/absolute path in JCR  where that property gets stored, you can read it.

Thanks

Avatar

Level 9

any chance you can share a full sample code? thanks!