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
BedrockMission!

Learn More

View all

Sign in to view all badges

Parent Resource ValueMap Value Sling Injector | AEM Community Blog Seeding

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,198 likes

Total Posts

6,369 posts

Correct Reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,198 likes

Total Posts

6,369 posts

Correct Reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

04-01-2021

BlogImage.jpg

Parent Resource ValueMap Value Sling Injector by Bounteous

Abstract

Pulling parent component properties into the child component is currently not supported by Sling Models. If we have a requirement to get a component property or properties from the parent component into the child component, we can do it by:
1. Use JCR API to adapt the Session/ResourceResolver to the respective parent component's node and get the properties.
2. Use the ComponentInhertianceValueMap API to get the inherited property value into the Sling Model.
3. Create a custom method, which iterates through the parent resources unless the resource is of type cq:Page to create a MergedValueMap or look for the property in each resource’s ValueMap.

Parent Resource ValueMap Value injector addresses the scenario in which one or more components have to inherit parent component properties. This annotation functions similarly to the @ValueMapValue annotation; it gets the parent component property into the Sling Model if available. Injections are available when adapting either a Resource or SlingHttpServletRequest object.

Use Cases
I created this feature to maximize code reuse and provide a generic solution to have a parent-child property inheritance.
1. A component with a parsys for dragging in other components. These 'child' components need to read a property from the 'parent' component.
2. A quiz or contest component, which has several steps as sub-components that need to access "FAQ," "Trademark Disclaimer," and "How to" properties of the parent component inside the sub-component HTML file.

Read Full Blog

Parent Resource ValueMap Value Sling Injector

Q&A

Please use this thread to ask the related questions.

AEM AEMEBlogSeeding Experience Manager