Expand my Community achievements bar.

Facing issues getting custom property value present in 'Advanced' tab.

Avatar

Level 9

Hi All,

We have created "basepage" whose sling:resourceSuperType="foundation/components/page". All the other templates/pages are extending from this. In "basepage" template, we have added certain custom properties[always populated with default values] in "Advanced" tab. Now, when I create a sample page of any template, I want to retrieve custom property say 'x'. 

Tried the below :

1] In my WCMUSe class, activate method  tried String custom=getInheritedProperties().get("x").toString();

But it is not working.

2] Tried final ValueMap properties = getResource().getValueMap();

custom = properties.get("x",String.class);

but not working.

Any thoughts/pointers/reference on this will be really helpful.

2 Replies

Avatar

Level 9

Hi All,

I even tried the  below , but not working.

protected InheritanceValueMap Prop;

res=getResource();

Prop = new HierarchyNodeInheritanceValueMap(res);

String value = Prop.getInherited("website",String.class);

Any thoughts/references will be really helpful

Avatar

Level 7

Anything which is in the page properties dialog should be present in the jcr:content node.

Try something like this

Resource pageResource = resourceResolver.getResource("pagePath"+ "/jcr:content");

String customProperty = pageResource.getValueMap().get("customProperty", "").toString();

 

Thanks

Tuhin