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