HTL Getting Property value from parent component | Community
Skip to main content
September 30, 2016
Solved

HTL Getting Property value from parent component

  • September 30, 2016
  • 4 replies
  • 3932 views

I have a component that has a certain property applied in a dialog. This component has a parsys for dragging in other components.

These 'child' components need to be able to read a property from the 'parent' component. How can this be achieved using the Javascript-use API?

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 Feike_Visser1

Here an example:


"use strict";
use(function () {
    var parent = resource.getParent();
    var props = parent.adaptTo(Packages.org.apache.sling.api.resource.ValueMap);

    return props.get("jcr:createdBy","");

});

4 replies

Feike_Visser1
Adobe Employee
Feike_Visser1Adobe EmployeeAccepted solution
Adobe Employee
October 1, 2016

Here an example:


"use strict";
use(function () {
    var parent = resource.getParent();
    var props = parent.adaptTo(Packages.org.apache.sling.api.resource.ValueMap);

    return props.get("jcr:createdBy","");

});

Feike_Visser1
Adobe Employee
Adobe Employee
October 1, 2016

BTW I raised this issue to make the getValueMap() available, to save a line of code :-)

https://issues.apache.org/jira/browse/SLING-6085

October 3, 2016

Thanks! This is perfect (minus the extra line of code of course). 

PS, I attended your sessions at Summit this year, really enjoyed them!

Feike_Visser1
Adobe Employee
Adobe Employee
October 3, 2016

thanks for the feedback!