Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

I need to place my all child nodes in navigation according to parent node


Level 3

Need to (navtitle and navlinks) and also the (Subnavtitle and Subnavlinks)

package com.kohler.jacobdelafon.core.models;

import java.util.ArrayList;picturemessage_1or3iezk.5jg.png

import java.util.Iterator;

import java.util.LinkedHashMap;

import java.util.List;

import java.util.Map.Entry;

import javax.annotation.PostConstruct;

import javax.inject.Inject;

import org.apache.sling.api.resource.Resource;

import org.apache.sling.api.resource.ResourceResolver;

import org.apache.sling.models.annotations.Model;

import org.apache.sling.models.annotations.Optional;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import com.day.cq.wcm.api.Page;

import com.day.cq.wcm.api.PageManager;

import com.kohler.jacobdelafon.core.beans.NavigationLinks;

@Model(adaptables = Resource.class)

public class JDHeaderNavigation {

private static final Logger LOG = LoggerFactory.getLogger(JDHeaderNavigation.class);



private String rootPath;


private ResourceResolver resolver;

private List<NavigationLinks> navigationLinksList;

private List<NavigationLinks> subNavLinksList;

private LinkedHashMap<NavigationLinks, List<NavigationLinks>> pagesListMap = new LinkedHashMap<>();

public LinkedHashMap<NavigationLinks, List<NavigationLinks>> getNavigationLinksList() {

return pagesListMap;


public String subnavtitle;

public void display() {

LOG.info("Inside Display");

Iterator sample = pagesListMap.keySet().iterator();

while (sample.hasNext()) {

String str = sample.next().toString();

LOG.info("String+ " + str);




public void init() {

LOG.debug("inside getNavigationLinksList");

try {

if (resolver != null && rootPath != null) {

Page rootPage = resolver.adaptTo(PageManager.class).getPage(rootPath);

LOG.info("rootpage+rootpage===========" + rootPage.getPath());

navigationLinksList = new ArrayList<NavigationLinks>();

subNavLinksList = new ArrayList<>();

if (rootPage != null) {

Iterator<Page> children = rootPage.listChildren();

while (children.hasNext()) {

NavigationLinks navigation = new NavigationLinks();

Page child = children.next();

if (!child.isHideInNav()) {

String firstLevelTitle = (null != child.getTitle()) ? child.getTitle() : "";




Iterator<Page> grandChildren = child.listChildren();

subNavLinksList = new ArrayList<>();

while (grandChildren.hasNext()) {

NavigationLinks navigation1 = new NavigationLinks();

Page grand = grandChildren.next();

if (!grand.isHideInNav()) {

navigation1.setNavTitle((null != grand.getTitle()) ? grand.getTitle() : "");





pagesListMap.put(navigation, subNavLinksList);





} catch (Exception ex) {

LOG.debug("inside exception " + ex.toString());



for (Entry<NavigationLinks, List<NavigationLinks>> en : pagesListMap.entrySet()) {

NavigationLinks obj1 = en.getKey();

LOG.info("Parent: " + obj1.getNavTitle() + "," + obj1.getNavLink());

for (NavigationLinks obj : en.getValue()) {

LOG.info("Children: " + obj.getNavTitle() + "," + obj.getNavLink());









<------------------------component Html----------------------->

<sly data-sly-use.nav="com.kohler.jacobdelafon.core.models.JDHeaderNavigation" />

<sly data-sly-list="${nav.navigationLinksList}">

<a href="${item.navLink}.html">${item.navTitle}</a>




giving me only the parent node  with links and logs showing me with child names please help me


6 Replies


Level 1

Hi keshav goud,

I'm seeing that this is posted to the Encore forums. To get you better assistance, what app forum should this actually be moved to?


Level 3

Hi Brandon Loshe ,

thanks for your reply,

Kindly guide me about what is what app forum can me send me any reference.


Level 2

One of your screens shows AEM, so I moved this to the Adobe Experience Manager forum

A quick Google turned up this link Developing with CRXDE Lite

It really helps people help you if you know what program you are using


Level 4

Did you write that Java code or copy it from somewhere?

The reason I am asking is that it seems strange that you know how to write that Java code for Experience Manager yet post in a Encore forum. 


Level 3



i know how to write java code but how present in the page that i need to know and  i think some changes in the java code also.

thanks for your reply