I am trying to get page properties using Sling Models in AEM 6.3 but always I am getting null.
resultsRootPath = getCurrentPage().getProperties().get("ResultsRootPath", String.class);
Path of property:
/components/content/results/cq:dialog/content/items/column/items/ResultsRootPath
Could you please let me know the correct ways to property value using Sling Models?
You can also do this:
@Model(adaptables = {SlingHttpServletRequest.class,Resource.class})
public class MyCustomModel{
@Inject
private InheritanceValueMap pageProperties;
@Inject
private ValueMap properties;
@PostConstruct
public void activate() {
String pageString = pageProperties.getInherited("myproperty", "default"); //InheritanceValueMap gives pageProperties Value Map and getInherited is used to fetch a particular property.
}
Refer this for more info: http://blogs.adobe.com/experiencedelivers/experience-management/valuemap-and-his-friend/