Skip to main content
Level 3
Sep 30, 2016 6:46 PM UTC
Solved

HTL Getting Property value from parent component

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.
Feike_Visser1
Feike_Visser1Accepted solution
Adobe Employee
Oct 1, 2016 4:36 PM UTC

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
Oct 1, 2016 4:36 PM UTC

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","");

});

Translate
Feike_Visser1
Adobe Employee
Adobe Employee
Oct 1, 2016 4:47 PM UTC

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

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

Translate
Level 3
Oct 3, 2016 7:51 PM UTC

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

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

Translate
Feike_Visser1
Adobe Employee
Adobe Employee
Oct 3, 2016 8:16 PM UTC

thanks for the feedback!

Translate