Last active
August 29, 2015 14:06
-
-
Save mrop/d125aa2b2610a3d09781 to your computer and use it in GitHub Desktop.
org.onehippo.cms7.essentials.components.CommonComponent#setContentBean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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