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

Avatar

Avatar
Boost 3
Level 2
keshav_goud
Level 2

Likes

3 likes

Total Posts

35 posts

Correct reply

0 solutions
Top badges earned
Boost 3
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Boost 3
Level 2
keshav_goud
Level 2

Likes

3 likes

Total Posts

35 posts

Correct reply

0 solutions
Top badges earned
Boost 3
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile
keshav_goud
Level 2

11-06-2019

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);

@Inject

@Optional

private String rootPath;

@Inject

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);

}

}

@PostConstruct

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() : "";

navigation.setNavTitle(firstLevelTitle);

navigation.setNavLink(child.getPath());

navigationLinksList.add(navigation);

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() : "");

navigation1.setNavLink(grand.getPath());

subNavLinksList.add(navigation1);

}

}

pagesListMap.put(navigation, subNavLinksList);

}

}

}

}

} catch (Exception ex) {

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

LOG.error(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());

subnavtitle=obj.getNavTitle();

}

}

display();

}

}

--------------------------------------------------------------------------

picturemessage_iknaym0p.wrw.png

<------------------------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>

${subnavtitle}

</sly>

----------------------------------------------------------------------

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

picturemessage_pkkqqfqp.nmp.png

Replies

Avatar

Avatar
Boost 1
Level 1
Brandon_Loshe
Level 1

Like

1 like

Total Posts

1 post

Correct reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
Brandon_Loshe
Level 1

Like

1 like

Total Posts

1 post

Correct reply

0 solutions
Top badges earned
Boost 1
View profile
Brandon_Loshe
Level 1

11-06-2019

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?

Avatar

Avatar
Boost 3
Level 2
keshav_goud
Level 2

Likes

3 likes

Total Posts

35 posts

Correct reply

0 solutions
Top badges earned
Boost 3
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Boost 3
Level 2
keshav_goud
Level 2

Likes

3 likes

Total Posts

35 posts

Correct reply

0 solutions
Top badges earned
Boost 3
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile
keshav_goud
Level 2

12-06-2019

Hi Brandon Loshe ,

thanks for your reply,

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

Avatar

Avatar
Give Back 3
Level 1
Peru_Bob
Level 1

Like

1 like

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Give Back 3
Give Back
Boost 1
View profile

Avatar
Give Back 3
Level 1
Peru_Bob
Level 1

Like

1 like

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Give Back 3
Give Back
Boost 1
View profile
Peru_Bob
Level 1

12-06-2019

What Adobe program are you using?

Avatar

Avatar
Boost 5
Level 2
John_T_Smith
Level 2

Likes

5 likes

Total Posts

28 posts

Correct reply

4 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Boost 5
Level 2
John_T_Smith
Level 2

Likes

5 likes

Total Posts

28 posts

Correct reply

4 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile
John_T_Smith
Level 2

12-06-2019

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

Avatar

Avatar
Give Back 5
Level 4
joeb21688728
Level 4

Likes

33 likes

Total Posts

60 posts

Correct reply

8 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 25
Give Back 10
Give Back
View profile

Avatar
Give Back 5
Level 4
joeb21688728
Level 4

Likes

33 likes

Total Posts

60 posts

Correct reply

8 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 25
Give Back 10
Give Back
View profile
joeb21688728
Level 4

12-06-2019

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. 

Avatar

Avatar
Boost 3
Level 2
keshav_goud
Level 2

Likes

3 likes

Total Posts

35 posts

Correct reply

0 solutions
Top badges earned
Boost 3
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Boost 3
Level 2
keshav_goud
Level 2

Likes

3 likes

Total Posts

35 posts

Correct reply

0 solutions
Top badges earned
Boost 3
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile
keshav_goud
Level 2

12-06-2019

Hi,

joeb216688728,

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