Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Fetching Parent Page Properties from Experience Fragment Component

rajaram33
Level 2
Level 2

Hi All,
I have a header component which uses a experience Fragment and in this XF i have a header component mapped. This Experience Fragment is been used inside my home page editable template. Now i am trying to access a page properties from my home page inside this header component mapped to Experience Fragment

Page Template > XF > Header Component(Access Page Properties).

Below is my code inside the header component model

@Self Resource resource; @PostConstruct protected void init() { try { InheritanceValueMap iProperties = new HierarchyNodeInheritanceValueMap(resource); String value = iProperties.getInherited("txPath",String.class);
I am always getting null value for txPath. I had checked the property value under /content/myprj/us/en/jcr:content and the value of txPath exists.
I am not sure whether i can access the property of a page from experience fragment component since both follows a different /content path(Not hierarchy).
Suggest Please

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution
Anudeep_Garnepudi
Correct answer by
Community Advisor
Community Advisor

@rajaram33 

To get current page properties, you can use pageProperties object in any of the component. All the properties of current page will be set pageProperties global object while sling resolves the resource and will be passed along all the resources in the page.

To get inherited pages properties, you can use inheritedPageProperties object. 

You can directly use these objects in HTL or can inject in Sling Model.

View solution in original post

0 Replies
Anudeep_Garnepudi
Correct answer by
Community Advisor
Community Advisor

@rajaram33 

To get current page properties, you can use pageProperties object in any of the component. All the properties of current page will be set pageProperties global object while sling resolves the resource and will be passed along all the resources in the page.

To get inherited pages properties, you can use inheritedPageProperties object. 

You can directly use these objects in HTL or can inject in Sling Model.

View solution in original post