[英]How to obtain page's organization in liferay portlet?
如何正確地在liferay portlet中獲取頁面的組織?
我試過了:
公司。 不是組織,而是門戶實例。
組。 是當前用戶的組,不是當前頁面的組。
更新
我在portlet類的doView
方法中。 我知道如何將我在這里可以獲得的任何東西傳遞給JSP,以通過EL/JSTL
進行訪問。
更新2
group.getOrganizationId()
始終返回零。
更新3
我用來准備變量的這段代碼
private void storeVariables(RenderRequest renderRequest) {
PortletPreferences prefs = renderRequest.getPreferences();
String image_id = (String) prefs.getValue("image_id", "communicator");
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
Company company = themeDisplay.getCompany();
Group group = themeDisplay.getScopeGroup();
log.info("group = {}", group);
long organizationId = group.getOrganizationId();
log.info("organizationId = {}", organizationId);
PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
String contextPath = renderRequest.getContextPath();
if( !contextPath.endsWith("/") ) {
contextPath = contextPath + "/";
}
renderRequest.setAttribute("images", images);
renderRequest.setAttribute("image", images.get(image_id));
renderRequest.setAttribute("image_id", image_id);
renderRequest.setAttribute("themeDisplay", themeDisplay);
renderRequest.setAttribute("portletDisplay", portletDisplay);
renderRequest.setAttribute("contextPath", contextPath);
}
更新3
JSP中的以下代碼返回空字符串
<!-- scopeGroupId = <c:out value="${scopeGroupId}"/> -->
群組是內容和頁面的容器,是站點,布局范圍,暫存等的內部實體。
在Liferay 6.1中,可以將站點 (在以前的版本中稱為社區 )與組織相關聯。 這取決於您所在的位置(在JSP中,在portlet類中,等等),但是,如果您有代表當前Group的實體,則可以編寫如下內容:
Organization organization = null;
if (group.isOrganization()) {
organization = OrganizationLocalServiceUtil.getOrganization(group.getOrganizationId());
}
希望能幫助到你。 詢問是否需要幫助才能檢索Group對象...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.