This document describes how to add a new portlet to the demo portal. With the sole purpose of giving some more understanding of how the demo works and how you can play with it. If further knowledge is needed the Jetspeed 2 documentation and should also be consulted since Hippo Portal is using Jetspeed as its portal engine and lots of concepts are explained there. As an example the hello portlet page is explained other pages can be added in similar fashion.
The most important building blocks of a portlet page are:
Take a look at the hello.psml in the demo-portal project. It describes which portlets are shown on the hello page.
It states it uses two portlets one menu portlet and a hello content portlet.
The fragment with id std-content is a layout portlet it will show all fragments nested inside itself.
It has currently one nested fragment:
<fragment id="std-test-content" type="portlet" name="demo-pa::ContentPortlet">
<preference name="ViewPage">
<value>WEB-INF/templates/hello/hello.ftl</value>
</preference>
</fragment>
The fragment describes which portal to use: ContentPortlet. This portlet needs a preference parameter ViewPage.
The portlets that can be used in an psml file are listed in a file called portlet.xml it is located
in the demo-pa project. We can add other portlets or use one already listed like the ContentPortlet.
In the portlet.xml you can describe the Java class implementing the portlet.
The portlet class is called FreeMarkerContentPortlet and is provided by Hippo Portal. The Portlet needs to be
configured with a ViewPage preference parameter which is a FreeMarker Template file. We could also use a Portlet that generates JSP
files or whatever we like. This case we use FreeMarker as a template engine. The preference ViewPage set in the fragment is
a file location and the portal expects the file to be in demo-pa. The example shows a hello.ftl file. In the file we can put freemarker scripting,
but we keep it simple and just put some simple html there. Note that we only make a fragment of html. The whole html
page with proper html begin and end tags is created by the portal.
The source code of the class can be viewed in hippo-portal-pac. It extends hippo portals BaseContentPortlet
this base portlet provides some services among which, freemarker rendering, xslt rendering and webdav connection to the repository.
The url for the hello page is: http://preview.localhost:8080/demo-portal/portal/site/hello. This url is rewritten
by Hippo Portal to show the hello.psml. This rewriting is done by means of the sitemap. The sitemap is an xml file stored in the repository.
The sitemap and the rest of the Hippo Portal content can be maintained by Hippo CMS. The sitemap describes the menu
of a site and all url rewriting goes through the sitemap. When we take a look at the repository that comes with Hippo Portal and see the sitemap we see an entry
for hello. The id attribute is used to look for a psml file with that name and the name attribute is used in the url.
In the demo some other portlets are also used they can all be found in the portlet.xml. For example in home.psml: