Need to (navtitle and navlinks) and also the (Subnavtitle and Subnavlinks)
package com.kohler.jacobdelafon.core.models;
import java.util.ArrayList;
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();
}
}
--------------------------------------------------------------------------
<------------------------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
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?
Hi Brandon Loshe ,
thanks for your reply,
Kindly guide me about what is what app forum can me send me any reference.
Views
Replies
Total Likes
What Adobe program are you using?
Views
Replies
Total Likes
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
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.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies