How to get page selectors from experience fragment. | Community
Skip to main content
Level 2
March 18, 2022
Solved

How to get page selectors from experience fragment.

  • March 18, 2022
  • 1 reply
  • 1184 views

I have this configuration.  (Experience fragments are dragged and dropped  and configured)

Page -> Xf1 ->XF2 -> componentA.

 

I need to get the selectors in compenentA from the page URL path. (/content/site/page.selector.html)

Issue: ComponentA is trying to find the selectors in the XF2  path. (/content/experiencefragemt/XF2.html)

Please let me know if this can be done.

I am using this code for getting the selectors.

request.requestPathInfo.selectors

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lukasz-m

Hi @sharathn8223803, could you please try below code. I think it should solve your problem.

import com.day.cq.commons.PathInfo;
// your Sling model implementation
// ....

PathInfo pathInfo = new PathInfo(request.getPathInfo());
pathInfo.getSelectors();

In general I did quick test and I was able to get list of selectors from page url on component level that was placed in XF.

1 reply

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
March 18, 2022

Hi @sharathn8223803, could you please try below code. I think it should solve your problem.

import com.day.cq.commons.PathInfo;
// your Sling model implementation
// ....

PathInfo pathInfo = new PathInfo(request.getPathInfo());
pathInfo.getSelectors();

In general I did quick test and I was able to get list of selectors from page url on component level that was placed in XF.