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

SOLVED

Reading data stored in separate nodes design dialog

sreenu539
Level 5
Level 5

design-dialog-nodes.pngHi,

 

I know to read design dialog values through for example: ${currentStyle.titleType} 

 

But how do you read design dialog data stored as separate nodes below component policy node. 

 

I have a multi field values stored as item nodes below component policy node.

 

I am trying to read it using data sly list ${curentStyle.link} which does not work as link is a child node below component policy node.

i appreciate any help, thanks.

AEM Design Dialog sightly
1 Accepted Solution
Vijayalakshmi_S
Correct answer by
Community Advisor
Community Advisor

Hi @sreenu539,

For getting policy programmatically, we need to make use of ContentPolicyManager and ContentPolicy API (We will be able to gain access to ContentPolicyManager from ResourceResolver)

ContentPolicyManager cntPolicyMgr = rescResolver.adaptTo(ContentPolicyManager.class);

Go through the methods exposed by the API and use accordingly. 

We will be able to get the policy and its properties (properties on the policy node). For accessing child nodes under policy node, should be either Resource or Node API. 

ContentPolicyManager API:

ContentPolicy API:

View solution in original post

6 Replies
Vijayalakshmi_S
Correct answer by
Community Advisor
Community Advisor

Hi @sreenu539,

For getting policy programmatically, we need to make use of ContentPolicyManager and ContentPolicy API (We will be able to gain access to ContentPolicyManager from ResourceResolver)

ContentPolicyManager cntPolicyMgr = rescResolver.adaptTo(ContentPolicyManager.class);

Go through the methods exposed by the API and use accordingly. 

We will be able to get the policy and its properties (properties on the policy node). For accessing child nodes under policy node, should be either Resource or Node API. 

ContentPolicyManager API:

ContentPolicy API:

View solution in original post

sreenu539
Level 5
Level 5

Is there a way to get content resource from sling request - I am trying to use content policy manager to populate data source elements for a dropdown in cq:dialog 

Resource contentResource = resolver.getResource((String) request.getAttribute(Value.CONTENTPATH_ATTRIBUTE)); 

Value.CONTENTPATH_ATTRIBUTE is displayed as deprecated

 

@Vijayalakshmi_S 

Vijayalakshmi_S
Community Advisor
Community Advisor

Could you please elaborate on the

  • Exact resource that you are trying to fetch with below snippet and
  • Servlet you are using for datasource logic is registered with paths or resourcetypes? Share the path used in either case.

"dataPath" property on the granite form fields is what will be available in "Value.CONTENTPATH_ATTRIBUTE". Couldn't relate which exact resource you are trying to retrieve with respect to the current context, hence the queries. 

nj2
Level 1
Level 1
Hi @sreenu539, I have the same use case, how di you manage to resolve this. Can you please share your solution. Thanks NJ
sreenu539
Level 5
Level 5

@nj2 

I have written a sling model to retrieve parent style node.

getAllowedLinks() {
allowedLinks = request.getResourceResolver().getResource(currentStyle.getPath()).getChild("links");

return allowedLinks;
}

in HTL:

data-sly-repeat : articleInsightsModel.allowedLinks