I'm trying to fetch values from a nested multifield. The content is stored as follows in jcr:
The code below is adding the languages to the value map at the country level. ${country.locale} outputs the locale value for both nodes under languages. Any ideas?
private List<ValueMap> getLanguageLinks(String nodeName) {
List<ValueMap> multifieldList = new ArrayList<ValueMap>();
try {
if (null != langSwitcherNode && langSwitcherNode.hasNode(nodeName)) {
Node propertyNode = langSwitcherNode.getNode(nodeName);
if (propertyNode.hasNodes()) {
NodeIterator iterator = propertyNode.getNodes();
while (iterator.hasNext()) {
Node childNode = iterator.nextNode();
multifieldList.add(resourceResolver.getResource(
childNode.getPath()).adaptTo(ValueMap.class));
if (childNode.hasNodes()){
Node languagesNode = childNode.getNode("languages");
if (languagesNode.hasNodes()){
NodeIterator childNodeIterator = languagesNode.getNodes();
while (childNodeIterator.hasNext()){
Node childLevel2Node = childNodeIterator.nextNode();
multifieldList.add(resourceResolver.getResource(
childLevel2Node.getPath()).adaptTo(ValueMap.class));
}
}
}
}
}
}
} catch (RepositoryException e) {
LOG.error("RepositoryException", e);
}
return multifieldList;
}
Views
Replies
Total Likes
What is happening when you use this component - any messages in the log?
Views
Replies
Total Likes
Nothing specific to the component.
Even if I don't access the language node in the sightly template, it's creating x number of empty divs (however many languages have been added). It's iterating through it, but adding it at the wrong level.
Views
Replies
Total Likes