I'm used to using nodes in sling and accustomed to looping through nodes with something like:
NodeIterator headerNode = currentNode.getNodes();
//loop through and do something
But how would I do this if I'm trying to loop through all the properties
of a resource. I'm really lost here. So currently I'm simply grabbing a single property of a resource. But what if I want to grab all the properties of said resource how would I do that?
Resource getResource = resourceResolver.getResource("/content/AboutPage/jcr:content/list");
ValueMap property = getResource.adaptTo(ValueMap.class);
String title = property.get("jcr:lastEdited", String.class);
Any help is greatly appreciated!
As ValueMap
extends java.util.Map you can use the entrySet() method:
Resource getResource = resourceResolver.getResource("/content/AboutPage/jcr:content/list");
ValueMap property = getResource.adaptTo(ValueMap.class);
for(Entry<String, Object> e : property.entrySet()) {
String key = e.getKey();
Object value = e.getValue();
//use the key and value here
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.