Skip to content

Instantly share code, notes, and snippets.

@mrop
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrop/d125aa2b2610a3d09781 to your computer and use it in GitHub Desktop.
Save mrop/d125aa2b2610a3d09781 to your computer and use it in GitHub Desktop.
org.onehippo.cms7.essentials.components.CommonComponent#setContentBean
/**
* Sets content bean onto request. If no bean is found, *no* 404 response will be set.
* NOTE: we first check if document is set through component interface,
* otherwise we try o fetch mapped (sitemap) bean
*
* @param documentPath
* @param request HstRequest
* @param response HstResponse
* @see #pageNotFound(org.hippoecm.hst.core.component.HstResponse)
*/
public void setContentBean(final String documentPath, HstRequest request, final HstResponse response) {
final HstRequestContext context = request.getRequestContext();
HippoBean bean;
if (!Strings.isNullOrEmpty(documentPath)) {
final HippoBean root = context.getSiteContentBaseBean();
bean = root.getBean(documentPath);
} else {
bean = context.getContentBean();
}
request.setAttribute(REQUEST_ATTR_DOCUMENT, bean);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment