Reputation: 307
I want to add my custom portlet to control panel programmatically. How can I do it ?
Upvotes: 1
Views: 650
Reputation: 11698
I think it is programmatically not-possible, since:
The portlets on Control Panel page are not stored in database as is the case for other pages in the portal in which the portlets are stored as typeSettings
in the Layout
table.
Instead the portlets that go on the control-panel page are determined by the value of the field _controlPanelEntryCategory
in PortletImpl
which denotes the value of tag <control-panel-entry-category>
in liferay-portlet.xml
and this value is set for each portlet by the PortletLocalServiceImpl#_readLiferayPortletXML
method which I think is only called everytime either when the server starts (in initEAR()
) or a portlet is deployed (in initWAR()
).
So it is required to have an entry in the liferay-portlet.xml
for the different <control-panel-entry-*>
tags to be able to add the portlet to control panel. And this is not possible programmatically.
This is as per my reasoning and understanding, but I would like to hear from Liferay masters if this is at all possible.
Upvotes: 0
Reputation: 48057
As you probably already know which portlet to make available in ControlPanel (there is only a limited number of portlets you write, right?) you don't need to make it fully programmatic, but can actually declare it like any other ControlPanel Portlet you have. (see your other question for information)
However, in order to make your administrative portlet to appear/disappear based on dynamic information, you can use the declaration of this element (taken from http://www.liferay.com/dtd/liferay-portlet-app_6_0_0.dtd)
<!--
The control-panel-entry-class value must be a class that implements
com.liferay.portlet.ControlPanelEntry and is called by the Control Panel to
decide whether the portlet should be shown to a specific user in a specific
context. The default value is set in portal.properties.
See:
http://docs.liferay.com/portal/6.0/javadocs/portal-service/com/liferay/portlet/ControlPanelEntry.html
-->
<!ELEMENT control-panel-entry-class (#PCDATA)>
Upvotes: 1