Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Gaurav Sharma
Getting the organization site a user is currently viewing
February 19, 2013 2:03 PM
Answer

Gaurav Sharma

Rank: Junior Member

Posts: 38

Join Date: November 1, 2012

Recent Posts

I have set up multiple organizations and each organization has their own organization site.



Each organization site has my portlet on one of it's pages. I need to be able to access the organization ID in my portlet. i.e. when a user is viewing my portlet from the Organization 1 site page, I want to display organization 1 specific data. When he is viewing it from the Organization 2 page, I want to show organization 2 specific data.

For this, all I need is the organization ID. How do you do this?
Minhchau Dang
RE: Getting the organization site a user is currently viewing
February 19, 2013 2:22 PM
Answer

Minhchau Dang

LIFERAY STAFF

Rank: Expert

Posts: 349

Join Date: October 22, 2007

Recent Posts

1themeDisplay.getScopeGroup().getOrganizationId()
Gaurav Sharma
RE: Getting the organization site a user is currently viewing
February 19, 2013 2:26 PM
Answer

Gaurav Sharma

Rank: Junior Member

Posts: 38

Join Date: November 1, 2012

Recent Posts

I'm using JSF, so I'll post the exact code I'm using:

1ThemeDisplay themeDisplay = (ThemeDisplay)FacesContext.getCurrentInstance().getExternalContext()
2                .getRequestMap().get(WebKeys.THEME_DISPLAY);
3_log.info("Org ID: " + themeDisplay.getScopeGroup().getOrganizationId());


Thanks Minhchau for that quick reply.
Vernon Singleton
RE: Getting the organization site a user is currently viewing
February 20, 2013 9:04 AM
Answer

Vernon Singleton

LIFERAY STAFF

Rank: Regular Member

Posts: 173

Join Date: January 14, 2013

Recent Posts

Hi Gaurav,

Looks like you are coming up to speed quickly with Liferay.

Just wanted to mention that you may like to get the themeDisplay this way:
1LiferayFacesContext.getInstance().getThemeDisplay();

Just make sure that you have the liferay-faces-portal jar included in your project.

Hope that helps,
Vernon
Gaurav Sharma
RE: Getting the organization site a user is currently viewing
February 20, 2013 9:32 AM
Answer

Gaurav Sharma

Rank: Junior Member

Posts: 38

Join Date: November 1, 2012

Recent Posts

Thanks Vernon. Looks like a much cleaner version to get the themeDisplay object.