The gadgets you have seen in previous recipes can be used only in the dashboard. It could be useful to manage the gadget as a portlet so that you can use all the portlet features, such as the security and event management, and manage them in any page of the portal.
You need the Gadget Wrapper Portlet . With it, you can add the gadget to any page of the portal and use the Portlet preferences for the configuration.
Follow these steps to make a gadget a portlet:
portlet.xml
file in the web application. Add the file inside the WEB-INF
folder. Here is the code:<portlet-app version="1.0"
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
<portlet>
<description xml:lang="EN">Skype Talk Portlet Portlet</description>
<portlet-name>SkypeTalkPortlet</portlet-name>
<display-name>Skype Talk Portlet</display-name>
<portlet-class>
org.exoplatform.webui.application.portlet.PortletApplicationController
</portlet-class>
<init-param>
<name>webui.configuration</name>
<value>/WEB-INF/conf/portlet/skypetalk/SkypeTalkPortlet/webui/configuration.xml</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
</supports>
<supported-locale>en</supported-locale>
<resource-bundle>
locale.portlet.gadget.SkypeTalkPortlet
</resource-bundle>
<portlet-info>
<title>Skype Gadget Portlet</title>
<short-title>Skype Gadget Portlet</short-title>
<keywords>SkypeTalk</keywords>
</portlet-info>
<portlet-preferences>
<preference>
<name>url</name>
<value>local://SkypeTalk</value>
</preference>
</portlet-preferences>
</portlet>
</portlet-app>
configuration.xml
file to be put inside the WEB-INF/conf/portlet/skypetalk/SkypeTalkPortlet/webui
folder:<webui-configuration> <application> <ui-component-root> org.exoplatform.gadget.webui.component.UIGadgetPortlet </ui-component-root> <state-manager> org.exoplatform.webui.application.portlet.ParentAppStateManager </state-manager> <application-lifecycle-listeners> </application-lifecycle-listeners> </application> </webui-configuration>
UIGadgetPortlet
class declared in the dashboard application. So in your pom.xml
add the dependency for this component:<dependencies> <dependency> <groupId>org.exoplatform.portal</groupId> <artifactId>exo.portal.portlet.dashboard</artifactId> <type>war</type> <version>3.2.0-GA</version> </dependency> </dependencies>
3.17.79.20