When working with eXo, it is important to not modify the source code. This will ensure compatibility with future upgrades, and will simplify support.
To customize your portal, you need to create an extension project by providing your own artifacts as a set of wars/jars/ears.
A custom extension contains two mandatory items:
extension webapp: contains resources and kernel configurations.
extension activator jar: identifies your webapp as a dependency of the portal container.
A sample extension package is provided here: http://anonsvn.jboss.org/repos/gatein/portal/trunk/examples/extension/
Once you have modified the sample extension to build your own, use "maven clean install" to create the archive files.
To deploy your extension in Tomcat, follow these steps:
Add the file sample-ext.war from sample/extension/war/target/ to the tomcat/webapps directory.
Add the folder starter from starter/war/target/ to the tomcat/webapps directory.
Rename the directory (unzipped folder) starter to starter.war.
This will only work if the starter.war is the last war file to be loaded, so you may need to rename it if your war files are loaded in alphabetical order.
Add the jar file exo.portal.sample.extension.config-X.Y.Z.jar from sample/extension/config/target/ to the tomcat/lib directory.
Add the jar file exo.portal.sample.extension.jar-X.Y.Z.jar from sample/extension/jar/target/ to the tomcat/lib directory.
For JBoss deployment and more details, refer to the Reference Guide.
You can create as many pages as you want within a single portal. Permissions can be defined to make them visible only to specific groups and/or users. This chapter describes how to define this structure.
The configuration of the "classic" portal can be found in the directory /src/main/webapp/WEB-INF/conf/sample-ext/portal/portal/classic of your extension webapp.
Portal:
The portal.xml file describes the layout and portlets common to all the pages of the portal.
<?xml version="1.0" encoding="ISO-8859-1"?>
<portal-config
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_0 http://www.gatein.org/xml/ns/gatein_objects_1_0"
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_0">
<portal-name>classic</portal-name>
<locale>en</locale>
<access-permissions>Everyone</access-permissions>
<edit-permission>*:/platform/administrators</edit-permission>
<properties>
<entry key="sessionAlive">onDemand</entry>
</properties>
<portal-layout>
<portlet-application>
<portlet>
<application-ref>web</application-ref>
<portlet-ref>BannerPortlet</portlet-ref>
<preferences>
<preference>
<name>template</name>
<value>par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl</value>
<read-only>false</read-only>
</preference>
</preferences>
</portlet>
<access-permissions>Everyone</access-permissions>
<show-info-bar>false</show-info-bar>
</portlet-application>
<portlet-application>
<portlet>
...
</portlet>
</portlet-application>
<portlet-application>
<portlet>
...
</portlet>
</portlet-application>
<page-body> </page-body>
<portlet-application>
<portlet>
...
</portlet>
</portlet-application>
</portal-layout>
</portal-config>
As you can see, each portlet can be configured with a set of preferences, which will be further detailed.
Pages:
The pages.xml file is used to describe the content of the pages of your portal. In other words, what will be inside the <page-body> tag of the portal.xml file above. Here is an example of the classic portal pages.xml.
<page>
<name>homepage</name>
<title>Home Page</title>
<access-permissions>Everyone</access-permissions>
<edit-permission>*:/platform/administrators</edit-permission>
<container id="ClassicBody" template="system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl">
<access-permissions>Everyone</access-permissions>
<container id="ClassicLeft" template="system:/groovy/portal/webui/container/UIContainer.gtmpl">
<access-permissions>Everyone</access-permissions>
<portlet-application>
<portlet>
<application-ref>presentation</application-ref>
<portlet-ref>SingleContentViewer</portlet-ref>
<preferences>
<preference>
<name>repository</name>
<value>repository</value>
<read-only>false</read-only>
</preference>
...
<preference>
<name>ShowTitle</name>
<value>false</value>
<read-only>false</read-only>
</preference>
</preferences>
</portlet>
<title>Introduce</title>
<access-permissions>Everyone</access-permissions>
<show-info-bar>false</show-info-bar>
<show-application-state>false</show-application-state>
<show-application-mode>false</show-application-mode>
</portlet-application>
</container>
</container>
</page>
This section is meant to help you organize the layout and structure of your portal. Review the "Working with applications" chapter to learn more about portlet configuration within the pages.xml file.
Navigation:
The navigation.xml is used to associate the links in your navigation (called page-node) with your portal pages.
If the pattern #{} is used then the label of the link will be loaded from the portal resource bundle (link to the ref guide about resource bundles
<?xml version="1.0" encoding="UTF-8"?>
<node-navigation>
<owner-type>portal</owner-type>
<owner-id>classic</owner-id>
<priority>1</priority>
<page-nodes>
<node>
<uri>home</uri>
<name>home</name>
<label>#{portal.classic.home}</label>
<page-reference>portal::classic::homepage</page-reference>
</node>
<node>
<uri>webexplorer</uri>
<name>webexplorer</name>
<label>#{portal.classic.webexplorer}</label>
<page-reference>portal::classic::webexplorer</page-reference>
</node>
</page-nodes>
</node-navigation>
This navigation tree can have multiple views inside portliest, such as breadcrumbs that render the current view node, the site map or the menu portlets.
For top nodes, the URI and the navigation node name must have the same value. For the other nodes, the URI is composed like <uri>contentmanagement/fileexplorer</uri> where 'contentmanagement' is the name of the parent node and 'fileexplorer' the name of the node (<name>fileexplorer</name>).
You can easily set the visibility of select pages and navigation to certain groups and users. Simply create pages.xml and navigation.xml files in folders named after the group and user to which you want to give permission:
sample-ext/portal/group/group-name/your files
sample-ext/portal/user/username/your files
One of the first steps in any web project is to integrate a graphic chart. This can be done entirely within your extension, by customizing the portal configuration.
In order to add a JavaScript library (for example JQuery), follow these steps:
Create the following folder, if it does not already exist: /war/src/main/webapp/WEB-INF/conf/script/groovy
Within this folder, create a JavascriptScript.groovy file
Add the following line to the groovy file
JavascriptService.addJavascript("Name_Of_Library", "/path_to/java_script/JavaScript_Lib.js", ServletContext);
For example:
JavascriptService.addJavascript("eXo.myproject.Jquery", "/javascript/eXo/myproject/jquery.js", ServletContext);