I could then get a hold of all available components on the current page.
With Experience Pages that doesn’t seem to work anymore. I simply get a null returned when calling resolvedSiteMapItem.getHstComponentConfiguration.
I get that the hst configuration has moved to the Document node that represents the Experience Page and might not qualify as hst configuration any more. However, can I get these components from somewhere else? Would I have to get them from the Exprience Page Document node? I simply can’t find this explained anywhere.
Hmmm, I think your code should’ve worked, but I can’t say I’ve tried it. But looking in the code for org.hippoecm.hst.site.request.ResolvedSiteMapItemImpl, it should return something. If it’s null, possibly you have the wrong sitemap item?
The strange thing is that the ResolvedSitemapItem also does not indicate that the this is in fact an Experience Page when I call resolvedSiteMapItem.isExperiencePage()
There might indeed be something wrong with my sitemap matching. I will investigate further.
in org.hippoecm.hst.site.request.ResolvedSiteMapItemImpl the does not support getting the HstComponentConfiguration when the current context is a Plain JAX-RS rest mount.
The logic in the ResolvedSiteMapItemImpl always gets the ResolvedSiteMapItem based on the current context and then tries to get the ContentBean which is then null.
RequestContextProvider.get().getContentBean()
Therefore it skips loading the Experience Page.
I’ve fixed this issue by implementing custom fallback logic to fetch the Experience Page Based on my own fetched ResolvedSiteMapItem:
HstComponentConfiguration componentConfiguration = myResolvedSiteMapItem.getHstComponentConfiguration();
if(componentConfiguration != null){
//move along, everything is fine
return componentConfiguration;
} else {
//check if this is an Experience Page
HstRequestContext hstRequestContext = RequestContextProvider.get();
HippoBean siteContentBaseBean = hstRequestContext.getSiteContentBaseBean();
HippoBean contentBean = siteContentBaseBean.getBean(myResolvedSiteMapItem.getRelativeContentPath());
Node node = contentBean.getNode();
try {
if (node.isNodeType("hst:xpagemixin") && node.hasNode("hst:xpage")) {
Node page = node.getNode("hst:xpage");
ExperiencePageService experiencePageService = HippoServiceRegistry.getService(ExperiencePageService.class);
HstComponentConfiguration xpageComponentConfiguration = experiencePageService.loadExperiencePage(page, myResolvedSiteMapItem.getHstSiteMapItem().getHstSiteMap().getSite(),
HippoWebappContextRegistry.get().getContext(hstRequestContext.getMount("my-site-alias").getContextPath()).getServletContext().getClassLoader());
//happy days
return xpageComponentConfiguration;
}
} catch (RepositoryException repositoryException) {
throw new ExperiencePageLoadingException("Failed to load HstPage", repositoryException);
}
}