Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

HTL Getting Property value from parent component

Avatar

Level 3

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?

1 Accepted Solution

Avatar

Correct answer by
Employee

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

});

View solution in original post

4 Replies

Avatar

Correct answer by
Employee

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

});

Avatar

Employee

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

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

Avatar

Level 3

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

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