Fórum

Get current group ID

John Bernardini, modificado 15 Anos atrás.

Get current group ID

Junior Member Postagens: 30 Data de Entrada: 16/06/08 Postagens Recentes
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?
thumbnail
Fuad Efendi, modificado 15 Anos atrás.

Re: [Liferay Forums][3. Development] Get current group ID

Regular Member Postagens: 180 Data de Entrada: 05/04/07 Postagens Recentes
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, modificado 15 Anos atrás.

RE: Re: [Liferay Forums][3. Development] Get current group ID

Junior Member Postagens: 30 Data de Entrada: 16/06/08 Postagens Recentes
For the jsp I havan't problem. What class can do it in the source code of the portlet?
thumbnail
Fuad Efendi, modificado 15 Anos atrás.

RE: Re: [Liferay Forums][3. Development] Get current group ID

Regular Member Postagens: 180 Data de Entrada: 05/04/07 Postagens Recentes
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, modificado 15 Anos atrás.

RE: Re: [Liferay Forums][3. Development] Get current group ID

Junior Member Postagens: 30 Data de Entrada: 16/06/08 Postagens Recentes
Thanks a lot. Now it run.
alain raybon, modificado 15 Anos atrás.

RE: Re: [Liferay Forums][3. Development] Get current group ID

New Member Postagens: 9 Data de Entrada: 26/05/08 Postagens Recentes
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, modificado 11 Anos atrás.

RE: Re: [Liferay Forums][3. Development] Get current group ID

Junior Member Postagens: 54 Data de Entrada: 16/07/12 Postagens Recentes
As suggested by Thiago you can use below method for groupId through themedisplay:
Long groupId = themeDisplay.getLayout().getGroupId();
thumbnail
Enrique Valdes Lacasa, modificado 9 Anos atrás.

RE: Re: [Liferay Forums][3. Development] Get current group ID

Junior Member Postagens: 92 Data de Entrada: 29/07/14 Postagens Recentes
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!
thumbnail
Bharamani P Tashildar, modificado 6 Anos atrás.

RE: Re: [Liferay Forums][3. Development] Get current group ID

Junior Member Postagens: 48 Data de Entrada: 27/08/14 Postagens Recentes
Hi,

How can I get current groupId in post login action?

As themeDisplay object not available in Postlogin action.

Any Input?

Thanks
thumbnail
Thiago Moreira, modificado 15 Anos atrás.

RE: Re: [Liferay Forums][3. Development] Get current group ID

Liferay Legend Postagens: 1449 Data de Entrada: 10/10/07 Postagens Recentes
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