2014-09-24 33 views
1

我有輕微的代碼是這樣的:AEM:在悅目(與multfield)迭代深層次的節點

<ul class="topnav" data-sly- use.topnav="com.company.companysite.util.myJavaClass" data-sly-list="${topnav.getPathValueMap}"> 
    <li>${!item}></li> (what do I put here??) 
</ul> 

和Java使用類方法是這樣的:

public ValueMap getPathValueMap() { 
     String parentPath = "/content/siteregion/en/jcr:content/toplevel/regionNames"; 
    ResourceResolver resourceResolver = getResourceResolver(); 
    Resource resource = resourceResolver.getResource(parentPath); 
    ValueMap vm = ResourceUtil.getValueMap(resource); 
    return vm; 

} 

問題:我在level/content/siteregion/en/jcr處有一個多字段對話框:content/toplevel/regionNames

我需要稍微代碼以迭代值的用戶放在萬事對話框

+0

你在萬事具備什麼樣的價值觀?如果你已經在使用一個類,我會建議在那裏進行處理,併爲這個多字段返回一個List。用你的例子,我認爲你只會迭代節點的所有屬性。 – Thomas 2014-09-25 09:24:46

+0

正確 - 我真的得到它的工作返回一個哈希映射視力 - 你知道如何從視覺上獲得關鍵和/或價值 - 所以這個工程$ {!item},但我想做一些像$ {!item.getValue }?現在使用$ {!item}我只從hashmap獲取密鑰,而不是使用$ {item.key}和$ {item.value}嘗試的值 – 2014-09-26 14:30:45

+0

? – Thomas 2014-09-29 14:44:46

回答

2

基礎上Sightly Intro Part 3這樣的事情應該地圖迭代工作:

<ul class="topnav" data-sly-use.topnav="com.company.companysite.util.myJavaClass" data-sly-list.pathMap="${topnav.getPathValueMap}"> 
    <li>${pathMap} : ${topnav.getPathValueMap[pathMap]}</li> 
</ul>