Making the gadget a portlet

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.

Getting ready

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.

How to do it...

Follow these steps to make a gadget a portlet:

  1. Log in to GateIn and click on the Edit Page link of the home page as shown in the following screenshot:
    How to do it...
  2. Now move the Skype Talk gadget in the page as shown in the following screenshot:
    How to do it...
  3. You will note that a Gadget Wrapper Portlet is created. Now edit the portlet by clicking on the pencil (at the top) in the created window. The Portlet Setting window will appear as shown in the following screenshot:
    How to do it...
  4. This new Gadget Wrapper Portlet instance now contains the gadget, and the gadget assumes the same properties of a portlet. As an example, resize the window again by choosing your size, and click on Save And Close button. That's it!
  5. If you want to transform it by XML configuration, you need to add the 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>
  6. This file needs a WEBUI 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>
  7. This file uses the features of the 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>
  8. Redeploy the Skype Talk application. Now you are ready to use the new portlet.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.79.20