Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

How do we write nested multifield using sling mapper?


Level 3

Is there a way to include nested multifield using sling mapper in a single file?

protected Resource resource;

List<Map<String, String>> marketData = new ArrayList<>();

List<Map<String, String>> marketContactData = new ArrayList<>();

@ChildResource(name="listItems", injectionStrategy = InjectionStrategy.OPTIONAL)
Resource listItemsResource;

protected void init() {

Iterable<Resource> listMarket = listItemsResource.getChildren();

Iterator<Resource> listItemsIterator = listMarket.iterator();

Resource listItemResource =;
ValueMap listItemResourceValueMap = listItemResource.adaptTo(ValueMap.class);
Map<String, String> marketItem = new HashMap<>();
marketItem.put("marketName", listItemResource.getValueMap().get("marketName", String.class));
marketItem.put("countryFlag", listItemResource.getValueMap().get("countryFlag", String.class));

Resource childItemsResource = listItemResource.getChild("listContacts");
if(null != childItemsResource){
Iterable<Resource> iterable = childItemsResource.getChildren();

Iterator<Resource> iterator = iterable.iterator();

Resource res =;
Map<String, String> marketContact = new HashMap<>();

ValueMap childResourceValueMap = res.adaptTo(ValueMap.class);
marketContact.put("name", res.getValueMap().get("name", String.class));
marketContact.put("email", res.getValueMap().get("email", String.class));



public List<Map<String, String>> getMarketData() {
return marketData;

public void setMarketData(List<Map<String, String>> marketData) {
this.marketData = marketData;
public List<Map<String, String>> getMarketContactData() {
return marketContactData;

public void setMarketContactData(List<Map<String, String>> marketContactData) {
this.marketContactData = marketContactData;

and here's the sightly

<sly data-sly-use.model="com.......models.Model">

<!--/* Iterate over contacts */-->
<li>Market Name: ${market.marketName}</li>
<li>MarketFlag: ${market.countryFlag}</li>

<li>Contact Name: ${}</li>
<li>Email: ${}</li>



It doesn't print the child nodes

1 Accepted Solution


Correct answer by
Community Advisor
0 Replies


Community Advisor

You can try below in nested way.


Create model class for Parent, Child and GrandChild and adapt to this models and create a list(child) of lists(grand children).


Correct answer by
Community Advisor