Expand my Community achievements bar.

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

Avatar

Level 1

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.

1 Reply

Avatar

Level 8

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