Super easy guide: inject your portlets wherever you want!
With our extension mechanism, we can now package and deploy new features easily in eXo Platform 4 as add-ons. You can deploy your own portlets but also existing ones, ready to use and ready to be deployed, with the add-ons manager:
Platform 4.1 has a new way to inject your portlets easily into pre-established places within the platform. It’s easy and we have covered most of the places you will need. Of course, the feature is extensible, which means you can define new places and then inject your portlets wherever you want
Let’s say you want to inject your new add-on into the Platform to add a simple new application on the top right of your Home:
Most of the changes are going to be made within your WAR file in the file
.This file is imported into configuration.xml within the WAR. The goal is to redefine a configuration file from the WAR without overriding the previous one present with the exact same location and name in your Platform. (documentation).
<external-component-plugins> <target-component>org.exoplatform.commons.addons.AddOnService</target-component> <component-plugin> <name>addPlugin</name> <set-method>addPlugin</set-method> <type>org.exoplatform.commons.addons.AddOnPluginImpl</type> <description>add application Config</description> <init-params> <value-param> <name>priority</name> <value>1</value> </value-param> <value-param> <name>containerName</name> <value>top-application-container</value> </value-param> <object-param> <!-- You must define here the portlet Name --> <name>helloPortlet</name> <description>sample hello portlet</description> <object type="org.exoplatform.commons.addons.PortletModel"> <field name="contentId"> <!-- In the container definition within your jar you have added a new container : sampleDynamicContainer This container will contain the targeted portlet helloPortlet. --> <string>sampleDynamicContainer/helloPortlet</string> </field> <!--The following values are optionals--> ... </object> </object-param> </init-params> </component-plugin> </external-component-plugins>
This file declares the new add-on but also the container name where you want to inject it.
Your JAR should contain your backend and the portal container configuration in file
<external-component-plugins> <!-- The full qualified name of the PortalContainerConfig —> <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component> <component-plugin> <!-- The name of the plugin --> <name>Add PortalContainer Definitions</name> <!-- The name of the method to call on the PortalContainerConfig in order to register the changes on the PortalContainerDefinitions --> <set-method>registerChangePlugin</set-method> <!-- The full qualified name of the PortalContainerDefinitionChangePlugin --> <type>org.exoplatform.container.definition.PortalContainerDefinitionChangePlugin</type> <init-params> <values-param> <name>apply.specific</name> <value>portal</value> </values-param> <object-param> <name>change</name> <object type="org.exoplatform.container.definition.PortalContainerDefinitionChange$AddDependencies"> <!-- The list of name of the dependencies to add --> <field name="dependencies"> <collection type="java.util.ArrayList"> <value> <string>sampleDynamicContainer</string> </value> </collection> </field> </object> </object-param> </init-params> </component-plugin> </external-component-plugins>
In this file we are updating the portlet configuration from the PortalContainerConfig to register the new sampleDynamicContainer in the PortalContainerDefinitions.
That’s just an example for a social intranet. With the new dynamic container we have provided, you are going to be able to inject your portlets more easily and safely.
You will find this example of packaging on the eXo Samples Repository. In the meantime, if you want to try ready-to-use add-ons for your Platform, check out the add-ons repository and of course you can submit your add-ons to the community!
Join the eXo tribe by registering for the community and get updates, tutorials, support, and access to the Platform and add-on downloads!
Make the most out of eXo Platform 4
Register to the next webinar and get a complete overview of what you can do with eXo Platform 4. Reserve your seat now!