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 to read public List<NavigationItem> getItems()

Avatar

Level 2

I have this on my custom component

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Component"
jcr:title="Footer"
sling:resourceSuperType="demo/components/navigation"
componentGroup="Content"/>

Since I extend navigation I want to list some pages but I cant achieve that, this is how I tried:

@ProviderType
public interface FooterModel extends Navigation {

}

 

@Model(adaptables = SlingHttpServletRequest.class, adapters = {FooterModel.class, ComponentExporter.class}, resourceType = FooterModelImpl.RESOURCE_TYPE, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class FooterModelImpl implements FooterModel, ComponentExporter {
@Model(adaptables = SlingHttpServletRequest.class, adapters = {FooterModel.class, ComponentExporter.class}, resourceType = FooterModelImpl.RESOURCE_TYPE, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class FooterModelImpl implements FooterModel, ComponentExporter {

static final String RESOURCE_TYPE = "demo/components/footer";

@Self
private SlingHttpServletRequest request;

@Self
@Via(type = ResourceSuperType.class)
private Navigation navigation;


@Override
public String getExportedType() {
return FooterModelImpl.RESOURCE_TYPE;
}

@Override
public List<NavigationItem> getItems() {
return null != navigation ? navigation.getItems() : null;
}

@Override
public String getAccessibilityLabel() {
return null != navigation ? navigation.getAccessibilityLabel() : null;
}
}

 getAccesibiliyLabel works fine and I get it on JSON but getItems() not

0 Replies

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now