5.3.1. Creating a gadget

Creating a gadget is very simple. To create a gadget through a Webapp, you need to create a sample bundle where you will add and deploy your gadget. This procedure walks you through steps to create a very simple gadget called Hello World.

  1. Add a very basic pom.xml file to your new Maven project as follows:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <name>Hello Gadget sample</name>
  2. Add a very basic web.xml file to the src/main/webapp/WEB-INF directory of your project:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" metadata-complete="true"
     xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  3. Add the following content to the HelloGadget.xml under the src/main/webapp/gadgets/HelloGadget directory:

    <?xml version="1.0" encoding="UTF-8"?>
      <ModulePrefs author="eXoPlatform" 
                   title="Hello World"
                   directory_title="Hello World"
                   description="The simplest gadget">
      <Content type="html">
        <div class='hello'>
          <h6>Welcome to Hello World gadget!</h6>
          <p><i>Powered by eXo Platform.</i></p>
  4. Add the following content to the gadget.xml file under the src/main/webapp/WEB-INF directory:

        xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_0 http://www.gatein.org/xml/ns/gadgets_1_0"
      <gadget name="HelloGadget">
  5. Create the target war with the Maven command: mvn clean install.

  6. Add the context name of the gadget war to $PLATFORM_TOMCAT_HOME/lib/custom-extension-config.jar!/conf/configuration.xml.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd http://www.exoplatform.org/xml/ns/kernel_1_2.xsd"

        <!-- The full qualified name of the PortalContainerConfig -->
          <!-- The name of the plugin -->
          <name>Change PortalContainer Definitions</name>
          <!-- The name of the method to call on the PortalContainerConfig in 
            order to register the changes on the PortalContainerDefinitions -->
          <!-- The full qualified name of the PortalContainerDefinitionChangePlugin -->
                <!-- The list of name of the dependencies to add -->
                <field name="dependencies">
                  <collection type="java.util.ArrayList">
                    <!-- The context name of gadget which is configured in the <display-name> tag of web.xml -->
  7. Restart the server, then deploy it in the application server by copying the generated web archive hello-gadget.war, from the target folder into the deployment folder where you unpacked the eXo Platform installation.

  8. Go to the Application Registry and click the Import Applications button. The new gadget will be added:

  9. Go to the Dashboard to insert the gadget in the page. Open the Dashboard Workspace by clicking the Add Gadgets link and choose the Hello World gadget. The result is as below:


Besides creating a gadget through a Webapp, you can also perform through UI.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus