Using SDI within AEM on a component with design mode settings | Community
Skip to main content
Level 2
October 12, 2021
Solved

Using SDI within AEM on a component with design mode settings

  • October 12, 2021
  • 1 reply
  • 923 views

I have created a component that outputs a text label and an image.  There is also a design setting provided for the template to set something relevant to the presentation.  When used on a page, it works fine.

 

However if I use Sling Dynamic Includes to enhance the component to have SSI with a TTL on it, the component fails.  The Style object used to get the design settings is null.

 

@Injectpublic LogoModel(
@ScriptVariable @Named("currentPage") final Page currentPage,
@ScriptVariable @Named("currentStyle") final Style currentStyle) {

 

Is this a known limitation of using SDI?  Is there another way of loading design mode settings into the model?

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 Anny0505

@james-appleby ,

 

you can access policy nodes by using below code snippets 

 

import org.apache.sling.api.resource.ResourceResolver;
import com.day.cq.wcm.api.policies.ContentPolicy;
import com.day.cq.wcm.api.policies.ContentPolicyManager;
import org.apache.sling.api.resource.ValueMap;

// placed within Sling Model or Java-Use API

ResourceResolver resourceResolver = resource.getResourceResolver();
ContentPolicyManager policyManager = resourceResolver.adaptTo(ContentPolicyManager.class);
ContentPolicy contentPolicy = policyManager.getPolicy(resource);
ValueMap policyValues = contentPolicy.getProperties();

thanks,

aruna 

1 reply

Anny0505
Community Advisor
Anny0505Community AdvisorAccepted solution
Community Advisor
October 16, 2021

@james-appleby ,

 

you can access policy nodes by using below code snippets 

 

import org.apache.sling.api.resource.ResourceResolver;
import com.day.cq.wcm.api.policies.ContentPolicy;
import com.day.cq.wcm.api.policies.ContentPolicyManager;
import org.apache.sling.api.resource.ValueMap;

// placed within Sling Model or Java-Use API

ResourceResolver resourceResolver = resource.getResourceResolver();
ContentPolicyManager policyManager = resourceResolver.adaptTo(ContentPolicyManager.class);
ContentPolicy contentPolicy = policyManager.getPolicy(resource);
ValueMap policyValues = contentPolicy.getProperties();

thanks,

aruna