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

Issue with Navigation component using Context Aware Configuration in Editable Templates

Level 3
Level 3


I have implemented dynamic Navigation component using Context Aware Configuration in Editable Templates.

I have followed Jörg Hoh  blog Sling Context-Aware configuration (part 2) | Things on a content management system

I have  Site1/en and Site2/fr

en have subpages like demo1,demo2...etc which are in navigation as well.

fr have subpages like test1,test2...etc which are in navigation as well.

Default path which i gave NavigationRootCAConfig is /content/site1/en.

Here I'm facing issue.Suppose if i'm in Site2/fr page i should get test1 and test2 in navigation but i'm getting demo1 and demo2.

It is always taking default path if i specify at structure level if i add login in any component and drag & drop i'm getting latest path.

Navigation component not taking latest page path in Editable template. I can see latest path in my in my logs.

Here is my code

@Configuration(label = "Navigation Root Context Aware Config")

public @interface NavigationRootCAConfig {

   @Property(label = "Navigation Root")

  String navigationRoot() default "/content/site1/en";


@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)

public class LeftNav {

   protected final Logger logger = LoggerFactory.getLogger(LeftNav.class);

   private String DEFAULT_NAV_ROOT = "/content/site1/en";

   private List<Page> navItems = new ArrayList<>();

   private Page currentPage;

   private String navigationRoot;

   private boolean collectAllPages;

   private int structureDepth;


  Resource resource;

   ResourceResolver resourceResolver;

   ComponentService componentService;

   protected void init() {"Nav Root Path : " + navigationRoot);"Collect All Pages : " + collectAllPages);"Structure Depth : " + structureDepth);

   if (StringUtils.isBlank(navigationRoot)) {

   navigationRoot = getNavigationRoot();"Navigation root {} .....", navigationRoot);

   navItems.addAll(componentService.getNavItems(navigationRoot, collectAllPages, structureDepth));



   public List<Page> getNavItems() {

   return navItems;


   public String getNavigationRoot() {

   currentPage = resourceResolver.adaptTo(PageManager.class).getContainingPage(resource);

  String path = currentPage != null ? currentPage.getPath() : "";

   if (!StringUtils.isBlank(path) && resource != null) {

   NavigationRootCAConfig navRootCAConfig = resource.adaptTo(ConfigurationBuilder.class).as(NavigationRootCAConfig.class);"Navigation root path {} *** ", navRootCAConfig.navigationRoot());

   navigationRoot = navRootCAConfig.navigationRoot();

  } else {

   navigationRoot = DEFAULT_NAV_ROOT;


   return navigationRoot;


   public void setNavigationRoot(String navigationRoot) {

   this.navigationRoot = navigationRoot;


   public boolean isCollectAllPages() {

   return collectAllPages;


   public void setCollectAllPages(boolean collectAllPages) {

   this.collectAllPages = collectAllPages;


   public int getStructureDepth() {

   return structureDepth;


   public void setStructureDepth(int structureDepth) {

   this.structureDepth = structureDepth;


   public Page getCurrentPage() {

   return componentService.getCurrentPage(navigationRoot, collectAllPages, structureDepth);


   public void setCurrentPage(Page currentPage) {

   this.currentPage = currentPage;


   public void setNavItems(List<Page> navItems) {

   this.navItems = navItems;


Can anyone help here?



1 Reply


can you provide your example in a github repo, so I can clone and analyze it? I find it hard to diagnose it here 🙂

How does your structure in /conf look like?



Level 3
Level 3


Does Context aware configuration works for assets, tags, XF as well or it just support site content?


From an API point of view it is not limited to Sites/pages.