I am trying to set some Clientlibs via the design dialog of the template but its not picking the property. When I further tried to look into PageImpl of the Core bundle found that its reading from currentDesign
My Page template extended from Core component why its not taking in consideration the policy set in conf node and taking /etc/designs rather as design path. Design dialog property should work as expected with core page component.
Here is the PageImpl of Core Page
And we just creating supertype of Page V2. I can't assume just to access the getClientLibCategories() we need to re implement the Page and write a logic again.
As I saw documentation on Editable Template clearly says it takes design from Policy node in /conf...
protected void addPolicyClientLibs(List<String> categories) {
if (currentStyle != null) {
Collections.addAll(categories, currentStyle.get(PN_CLIENTLIBS, ArrayUtils.EMPTY_STRING_ARRAY));
}
}
clientLibCategoriesJsHead = currentStyle.get(PN_CLIENTLIBS_JS_HEAD, ArrayUtils.EMPTY_STRING_ARRAY);
I tried printing on page currentDesign.path() and its results in /etc/designs/default
I am not sure how we can take this from the policies. Is there something we need to do in order to get the design from the policy node?
I can see the policy node having the property clientlibs and clientlibsJsHead , but I believe it's not being picked as the currentDesign is still pointing to defalt design in /etc. And if I delete /etc/designs/default its picking /libs/settings/wcm/designs/default instead of picking from /conf/<project>/setting...policy
Solved! Go to Solution.
Views
Replies
Total Likes
After debugging further and looking into logs we found the Core Page model object was overridden, as a custom page model implementing Page model and applied to the same resource type, was written. So the logs saying it cannot find any method in the PageImpl when tried printing. We got this resolved by implementing those methods or, removing that implementation of Page model class.
Thanks @Ankur_Khare and @Vijayalakshmi_S !!
Hi @rohanr43729387,
Policies set for a component can be accessed programmatically using ContentPolicyManager/ContentPolicy API.
In this case, it is the policy of the page component.
We can use one of the below two ways
Resource policyPath = rescResolver.getResource("/conf/we-retail/settings/wcm/policies/we-retail/components/structure/page/policy_content_page");
ContentPolicy cntPolicyFromResc = policyPath.adaptTo(ContentPolicy.class);
ValueMap cntPolicyProps = cntPolicyFromResc.getProperties(); // can access direct property from the valuemap object. (clientlibs/clientlibsJsHead)
for(Entry<String, Object> entry : cntPolicyProps.entrySet()) {
log.info("Value Map of resc - key={} and value={}", entry.getKey(), entry.getValue());
}
ContentPolicyManager cntPolicyMgr = rescResolver.adaptTo(ContentPolicyManager.class);
Resource pageCntResc = rescResolver.getResource("/content/we-retail/en/jcr:content"); // argument here can be set dynamically based on the place where we write this code. Eg. Can be retrieved from page object - page.getContentResource()
ContentPolicy cntPolicy = cntPolicyMgr.getPolicy(pageCntResc);
ValueMap cntPolicyProps = cntPolicy.getProperties();
for(Entry<String, Object> entry : cntPolicyProps.entrySet()) {
log.info("Value Map key={} and value={}", entry.getKey(), entry.getValue());
}
@Vijayalakshmi_S I know programmatically it's possible but being a Page template extended from Core component why its not taking in consideration the policy set in conf node and taking /etc/designs rather as design path. Design dialog property should work as expected with core page component.
Here is the PageImpl of Core Page
And we just creating supertype of Page V1. I can't assume just to access the getClientLibCategories() we need to re implement the Page and write a logic again.
As I saw documentation on Editable Template clearly says it takes design from Policy node in /conf...
Views
Replies
Total Likes
Did you try to add the clientlib from page properties of aem template?
Views
Replies
Total Likes
After debugging further and looking into logs we found the Core Page model object was overridden, as a custom page model implementing Page model and applied to the same resource type, was written. So the logs saying it cannot find any method in the PageImpl when tried printing. We got this resolved by implementing those methods or, removing that implementation of Page model class.
Thanks @Ankur_Khare and @Vijayalakshmi_S !!
Views
Likes
Replies
Views
Likes
Replies