Expand my Community achievements bar.

SOLVED

How to get page selectors from experience fragment.

Avatar

Level 2

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

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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.