Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Michael Illgner
Detecting Control Panel
February 11, 2010 5:34 AM
Answer

Michael Illgner

Rank: Junior Member

Posts: 33

Join Date: June 30, 2009

Recent Posts

Hi
I have a portlet which may be instantiated on any page, but should also work in the control panel with a slightly different behavior ?

How can a portlet detect if its instantiated in the control panel ? Is there special flag in the ThemeDisplay or something like that ?

Regards
Amos Fong
RE: Detecting Control Panel
February 11, 2010 10:12 AM
Answer

Amos Fong

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1954

Join Date: October 7, 2008

Recent Posts

Hi Michael,

This is how it's done in ServicePreAction.java:

1if (group.getName().equals(GroupConstants.CONTROL_PANEL)) {


You should be able to get the current group from themeDisplay.getScopeGroup()
Michael Illgner
RE: Detecting Control Panel
February 12, 2010 12:48 AM
Answer

Michael Illgner

Rank: Junior Member

Posts: 33

Join Date: June 30, 2009

Recent Posts

Thanks,
This seems to work

But you have to retrieve the group from the layout, it is not the scopegroup.
1if (layout.getGroup().getName().equals(GroupConstants.CONTROL_PANEL)) {
Amos Fong
RE: Detecting Control Panel
February 16, 2010 6:20 PM
Answer

Amos Fong

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1954

Join Date: October 7, 2008

Recent Posts

oh right you are correct, my mistake.

Scope group would refer to the community/organization you are administering from the control panel.
Guillaume K
RE: Detecting Control Panel
April 11, 2012 1:22 AM
Answer

Guillaume K

Rank: New Member

Posts: 11

Join Date: March 6, 2012

Recent Posts

Hello,

Thanks for the info but how to retrieve the layout object inside a PortletAction object ?
Thanks
Pankaj Kathiriya
RE: Detecting Control Panel
April 11, 2012 1:35 AM
Answer

Pankaj Kathiriya

Rank: Liferay Master

Posts: 721

Join Date: August 4, 2010

Recent Posts

Hi Guillaume Kuhmel,

You can use themeDisplay objec to get current layout you want.


HTH,
Regards,
Pankaj

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!