繁体   English   中英

如何在Liferay Portlet中获取页面的组织?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM