Hi
My goal is to create a token whenever a page is rendered that contains a component called someTeaser. This someTeaser component renders in the template after the content and before the footer and is not editable. It is configured fixed in the template structure.
The problem appears when I want to create a servlet for someTeaser. This component is not in the Content Repository crxde.
@SlingServletResourceTypes(
resourceTypes = {Constants.ResourceTypes.SOME_TEASER},
selectors = {"token"},
extensions = Constants.Extensions.JSON
)
The resource for this component is /conf/xx/settings/wcm/templates/someTemplate/structure/jcr:content/root/main/container/someTeaser. This resource cannot be resolved in publish. It is not under content but rather under conf.
Request URL: https://publish_server/conf/xxx/settings/wcm/templates/someTemplate/structure/jcr:content/root/main/...
Request Method: GET
Status Code: 404 Not Found
An alternative solution would be to use define resourceTypes = {Constants.ResourceTypes.PAGE} in the servlet but then every page will check if it has the selector token.
Is there a better solution for this?
Views
Replies
Total Likes
Hi @anasustic
Can you please be more clear on your query? I am not able to understand "This component is not in http://localhost:4506/crx for any detailHelp pages."
Thanks,
Kiran Vedantam.
Hi @Kiran_Vedantam yes, of course. I tried to be more clear on the original description.
Looks like you are using editable templates in your site.
That means, that at rendering time the content of the template is merged with the content of the actual page (unlike static templates where the template is copied into the location where the resulting page is to be created). That means in the case of editable templates you don't find necessarily find all components below the page resources anymore (when using the repository browser).
So you can request your resource via /content although it's not persisted there in the JCR repository (as node).
Thanks @Jörg_Hoh
I was able to request the token for the container that is avaliable in the JCR repository.
String containerPath = PathBuilder.with(currentPage.getPath())
.slash(AemConstants.JCR_CONTENT)
.slash("root/main/container")
.build();
and resolve the container url nicely using
resourceResolver.map(path)
.
Views
Like
Replies