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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Using SDI within AEM on a component with design mode settings

Avatar

Level 1

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@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 

View solution in original post

0 Replies

Avatar

Correct answer by
Community Advisor

@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