title: How do I get a selector from a sling Resource
body: <p>I have two Sling Models:</p>
  
  <pre><code>@Model(adaptables = {SlingHttpServletRequest.class, Resource.class}, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
  public class VideoGridItem {
  
    @SlingObject
    private Resource resource;
  
    @SlingObject
    private SlingHttpServletRequest slingHttpServletRequest;
  
  
    @PostConstruct
    public void initVideoGridItem() {
      String[] selectors = slingHttpServletRequest.getRequestPathInfo().getSelectors();
      insideGrid = selectors == null || selectors.length == 0 ? false : Arrays.stream(selectors).anyMatch("grid"::equals);
      url = URLUtils.addHTMLIfPage(resource.getResourceResolver(), linkUrl);
    }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
  public class VideoListing {
  
    private List&lt;String&gt; videoResourcePaths;
  
    @PostConstruct
    final void init() {
  
    }
  
  }
  </code></pre>
  
  <p>I call the VideoGridItem component (technically the resource which references the model) from the video-listing component using HTL:</p>
  
  <pre><code>  &lt;sly data-sly-list.videoResourcePath="${model.videoResourcePaths}"&gt;
      &lt;sly data-sly-resource="${videoResourcePath @ wcmmode='disabled', addSelectors='grid'}" data-sly-unwrap="true"&gt;&lt;/sly&gt;
    &lt;/sly&gt;
  </code></pre>
  
  <p>Now, when I debug the code, inside initVideoGridItem, slingHttpServletRequest is null. Fair enough, this resource isn't being directly requested, but I still need to be able to access the selector "grid". Is there a way I can do this from the VideoGridItem.resource?</p>