Hi All,
We have sightly code which was working fine in 6.1 and stopped working in 6.3.
Code to iterate over Map which is a list of String.
Sightly (HTL)
<sly data-sly-use.table="${'my.models.Table'}">
<div>
<table data-sly-list.row="${table.rowList}">
<tr data-sly-list.columnCell="${table.rowList[row]}">
<td>
${columnCell}
</td>
</tr>
</table>
</div>
</sly>
Model Java:
Map<Integer,List<String>> myMap = new HashMap<Integer,List<String>>();
for(int i=1;i<=3;i++)
{
List<String> list = new ArrayList<String>();
list.add("" + i);
list.add("" + i*i);
list.add("" + i*i*i);
myMap.put(new Integer(i-1),list);
}
This sightly code stops working where ${table.rowList[row]} always returns null and hence inner loop does not execute.
Is there any change in 6.3 with respect to sightly where rowList[row] kind of notation is disabled ? Could not find something similar on google.
I also tried iterator way and passed the item in the array index. But that also does not solve the issue.
The way I fixed it was by converting the Map key from Integer to String.
myMap.put(Integer.parseInt(i-1),list)
No change in Sightly component.
Not sure how this worked in 6.1 and not in 6.3.
kautuksahni / smacdonald2008 : Have you heard about this type of issue before ?
And we were able to identify the same pattern for 2 other components and fix it in the same way.
Basically the array notation with square bracket is not working where the Model is returning HashMap(Interger,List<Object>).
表示
返信
いいね!の合計
Can you quickly try with Map<Integer,String> myMap = new HashMap<Integer,String>(); ?
表示
返信
いいね!の合計
See this artilce to learn how to work with HTL and Collections -- Scott's Digital Community: Creating a HTL Repeating Data Set 6.3 Component that uses Sling Models
表示
返信
いいね!の合計
Actually the above article - shows use of Sling Models and a Multi-field. Its useful but does not show use of a Java collection. See this 6.2 artilce where we use WCMUSePojo and show use of a Java collection in the Java code and how to render the values: Adobe Experience Manager Help | Creating an Adobe Experience Manager HTL component that displays a r...
表示
返信
いいね!の合計
Hi smacdonald2008:
Thanks for the article but that uses a normal java collection and I have evidences in my code that this works fine.
The issue we are observing is especially when there is a key which is Integer object and in sightly we use [] notation. See my code above. This used to work fine in 6.1
表示
返信
いいね!の合計
Can you show what you are doing in the Java code.
表示
返信
いいね!の合計