【问题标题】:How to obtain page's organization in liferay portlet?如何在liferay portlet 中获取页面的组织?
【发布时间】:2013-04-30 06:52:39
【问题描述】:

如何正确获取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}"/> -->

【问题讨论】:

    标签: java liferay portlet


    【解决方案1】:

    是内容和页面的容器,是网站、布局范围、登台等的内部实体。

    在 Liferay 6.1 中,站点(在以前的版本中称为社区)可以与组织相关联。这取决于您所在的位置(在 JSP 中、在 portlet 类中等),但是,如果您有代表当前组的实体,您可以编写如下内容:

    Organization organization = null;
    
    if (group.isOrganization()) {
        organization = OrganizationLocalServiceUtil.getOrganization(group.getOrganizationId());
    }
    

    希望对您有所帮助。询问您是否需要帮助才能检索 Group 对象...

    【讨论】:

      猜你喜欢
      • 2018-03-08
      • 2012-01-13
      • 1970-01-01
      • 2021-08-16
      • 1970-01-01
      • 1970-01-01
      • 2012-11-27
      • 1970-01-01
      • 2012-11-21
      相关资源
      最近更新 更多