AEM 6.1: How to get component included with data-sly-resource in SlingFilter?

Avatar

Avatar

korben-ne-dalla

Avatar

korben-ne-dalla

korben-ne-dalla

12-03-2018

I have a page component (/libs/wcm/foundation/components/page) with other included components like:

<sly data-sly-resource="${'search' @ resourceType='/apps/project/components/search'}" sly/> 

How can I get a list of these components in a Sling Filter? I tried to use scope SlingFilterScope.COMPONENT, but all components included with data-sly-resource are ignored and I get only components added to parsys.

My "doFilter" method:

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)

  throws IOException, ServletException {

  Object resource = request.getAttribute("org.apache.sling.api.include.resource");

  if (resource instanceof Resource) {
  String resourceType = resource.getResourceType();
  }

  chain.doFilter(request, response);
}

Thanks for any help.

Replies

Avatar

Avatar

Hemant_arora

Avatar

Hemant_arora

Hemant_arora

12-03-2018

do you see the component node(search component) created under page node (/content/project_name/en/...)? one way you can do is get the page resource and iterate all the component nodes. Can you share the AEM version? Let me try