hi,
i am using aem 6.1
i have data in java jsonarray
is there any way to access jsonarray to sightly in data-sly-list?
java looks like :
@Model(adaptables = Resource.class)
public class Details {
private JSONArray objList;
public JSONArray getList() {
return objList;
}
@PostConstruct
private void functionName(){
objList=new JSONArray();
//get value into objList; --which is working
}
}
html :
<sly data-sly-use.obj="${'com.abc.Details}" data-sly-unwrap>
<sly data-sly-list.obj="${obj.objList}"></sly> --> not getting value here
</sly>
let me know if more details are required.
Solved! Go to Solution.
Views
Replies
Total Likes
Your Issue is you are not calling the method (defined in the Sling Model Java class) that returns the List. Assume we have this method - which returns a collection:
public
List<Columns> getCol() {
return
col;
}
To invoke it from HTL - we use: (the method is called by dropping get and simply the name of the remaining part of the getter method - in the case "col")
<div class="row">
<div data-sly-list="${colControl.col}" data-sly-unwrap>
<div data-sly-attribute="${item.clssAttr1}">
<div data-sly-resource="${@ path='par_0', resourceType='foundation/components/parsys'}" data-sly-unwrap></div>
</div>
<div data-sly-attribute="${item.clssAttr2}">
<div data-sly-resource="${@ path='par_1', resourceType='foundation/components/parsys'}" data-sly-unwrap></div>
</div>
</div>
</div>
See this AEM Community Article to learn how to work with Collections (List) and HTL so the data in the Collection is rendered in the component.
Creating a custom Touch UI Grid Component for Adobe Experience Manager
Hope this helps...
Views
Replies
Total Likes
Your Issue is you are not calling the method (defined in the Sling Model Java class) that returns the List. Assume we have this method - which returns a collection:
public
List<Columns> getCol() {
return
col;
}
To invoke it from HTL - we use: (the method is called by dropping get and simply the name of the remaining part of the getter method - in the case "col")
<div class="row">
<div data-sly-list="${colControl.col}" data-sly-unwrap>
<div data-sly-attribute="${item.clssAttr1}">
<div data-sly-resource="${@ path='par_0', resourceType='foundation/components/parsys'}" data-sly-unwrap></div>
</div>
<div data-sly-attribute="${item.clssAttr2}">
<div data-sly-resource="${@ path='par_1', resourceType='foundation/components/parsys'}" data-sly-unwrap></div>
</div>
</div>
</div>
See this AEM Community Article to learn how to work with Collections (List) and HTL so the data in the Collection is rendered in the component.
Creating a custom Touch UI Grid Component for Adobe Experience Manager
Hope this helps...
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies