Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
John Bernardini
Get current group ID
July 14, 2008 6:41 AM
Answer

John Bernardini

Rank: Junior Member

Posts: 30

Join Date: June 16, 2008

Recent Posts

hi,

I'm developing a portlet that shows journal articles. I need to specify the community id to filter content in each community. How can I get community id in my code?
Fuad Efendi
Re: [Liferay Forums][3. Development] Get current group ID
July 14, 2008 6:55 AM
Answer

Fuad Efendi

Rank: Regular Member

Posts: 175

Join Date: April 5, 2007

Recent Posts

Use portletGroupId (predefined variable) in your JSP.


Quoting John Bernardini at Liferay's Community Forums <no-reply@liferay.com>:

> hi,
>
> I'm developing a portlet that shows journal articles. I need to
> specify the community id to filter content in each community. How can
> I get community id in my code?
> --
> Liferay Community Forum
> mb.239390.1065754@events.liferay.com
> http://www.liferay.com/web/guest/community/forums/-/message_boards/message/1065754
John Bernardini
RE: Re: [Liferay Forums][3. Development] Get current group ID
July 14, 2008 6:58 AM
Answer

John Bernardini

Rank: Junior Member

Posts: 30

Join Date: June 16, 2008

Recent Posts

For the jsp I havan't problem. What class can do it in the source code of the portlet?
Fuad Efendi
RE: Re: [Liferay Forums][3. Development] Get current group ID
July 14, 2008 7:11 AM
Answer

Fuad Efendi

Rank: Regular Member

Posts: 175

Join Date: April 5, 2007

Recent Posts

You need to pass it to source code as parameter; source code for
portlet have no knowledge on potlet instance of community... "Layout"
belongs to "Community", "Portlet Instance" belongs to "Layout"...

Quoting John Bernardini at Liferay's Community Forums <no-reply@liferay.com>:

> For the jsp I havan't problem. What class can do it in the source
> code of the portlet?
> --
> Liferay Community Forum
> mb.239390.1065815@events.liferay.com
> http://www.liferay.com/web/guest/community/forums/-/message_boards/message/1065815
John Bernardini
RE: Re: [Liferay Forums][3. Development] Get current group ID
July 14, 2008 7:25 AM
Answer

John Bernardini

Rank: Junior Member

Posts: 30

Join Date: June 16, 2008

Recent Posts

Thanks a lot. Now it run.
Thiago Leão Moreira
RE: Re: [Liferay Forums][3. Development] Get current group ID
July 14, 2008 7:28 AM
Answer

Thiago Leão Moreira

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1433

Join Date: October 10, 2007

Recent Posts

Hi John,

Try this:

ThemeDisplay themeDisplay= (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
long portletGroupId= themeDisplay.getPortletGroupdId();

Take a look at javadoc for further information.

Regards
rayan alain
RE: Re: [Liferay Forums][3. Development] Get current group ID
February 3, 2009 9:58 AM
Answer

rayan alain

Rank: New Member

Posts: 9

Join Date: May 26, 2008

Recent Posts

hi Fuad,
can u plz be more clear, coz i have the same probleme of John, how i can get the current community, (current groupid)

thx
Vaibhav Mittal
RE: Re: [Liferay Forums][3. Development] Get current group ID
January 15, 2013 5:16 AM
Answer

Vaibhav Mittal

Rank: Junior Member

Posts: 54

Join Date: July 16, 2012

Recent Posts

As suggested by Thiago you can use below method for groupId through themedisplay:
Long groupId = themeDisplay.getLayout().getGroupId();
Enrique Valdes Lacasa
RE: Re: [Liferay Forums][3. Development] Get current group ID
January 22, 2015 2:38 PM
Answer

Enrique Valdes Lacasa

Rank: Junior Member

Posts: 69

Join Date: July 29, 2014

Recent Posts

This last solution worked for me in Liferay 6.1.1 CE. The solution proposed by Thiago is deprecated by this version I believe, but it might still work. Thanks to both!