简体   繁体   English

如何在Login -Liferay之后获得OrganizationId

[英]How to get OrganizationId after Login -Liferay

我正在使用liferay6.I在liferay中部署了我的web应用程序。登录后,它被重定向到一个页面。在那个jsp页面中,我想在javascript变量中设置登录用户的组织ID。我怎么能这样做。可以任何人请解释。

  1. You can get userId of logged in User by themeDisplay.getUserId() 您可以通过themeDisplay.getUserId()获取登录用户的userId
  2. Using this userId , you can get the User's Organizations by OrganizationLocalServiceUtil.getUserOrganizations(userId) 使用此userId ,您可以通过OrganizationLocalServiceUtil.getUserOrganizations(userId)获取用户的组织
  3. Then you can iterate through the Organizations to get the organizationId you require. 然后,您可以遍历组织以获得所需的组织。
 com.liferay.portal.model.Group currentGroup;
    long organizationId = 0;
    try {
        currentGroup = themeDisplay.getLayout().getGroup();
        if (currentGroup.isOrganization()) {
            organizationId = currentGroup.getClassPK();
        }
    } catch (Exception e) {
        log.error(e);
    }

    return organizationId;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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