•  
Main
About Hippo Portal
Documentation
Community
Other

Getting started: Hello World

This document describes building and deploying a Hippo Portal with one standard Pick A Number portlet and one sample Hello World portlet, that retrieves its content from Hippo Repository. The content of the Hello World portlet will be adjustable with Hippo CMS.

In short, the following tasks should be performed:

  • Set up the required component applications Hippo Repository, Hippo CMS and Tomcat.
  • Set up the development environment for Hippo Portal.
  • Set up a Getting Started Portal project based on Hippo Portal and configure it.
  • Set up a Hello World Portlet Application project based on Hippo Portal components and configure it with a standard Hello World Portlet.
  • Download a Apache Jetspeed-2's Demo application containing the Pick-A-Number Portlet.
  • Build and deploy the portal with portlet applications on Tomcat.

Requirements

Before building and deploying your own portal, several component applications have to be in place.

  • Install Hippo Repository, containing site navigation and the content of the Hello World portlet. For this track, download this release .
  • Install Hippo CMS. With it the content of the Hello World portlet can be managed.
  • Install a webserver to run your portal on. In this documentation Tomcat 5.5 is described.
  • Install a database to hold portal data. In this documentation a mysql database is used. For this track, be sure to create a database by the name of helloWorldPortal

See component applications for details on how to install these.

Furthermore, to build the portal, you will need:

  • JDK 1.5 or more. Environment variable JAVA_HOME should point to it.
  • Maven-1 build tool for building your Hippo portal, see the build requirements for details.
  • The Hippo Portal Maven-1 plugin, see this reference for details.

Setting up the Getting Started Portal

To start with, you need to set up the portal project, which is based on Hippo Portal components. Later the page and layout will be configured.

Create a portal project

Create a project for the portal to be built. Create a folder on your filesystem for the new project. For the remainder of the document, we assume you created the folder

c:/projects/gettingstarted-portal

for this purpose. Let's call this project the "Getting Started Portal". Open a console in the folder you just created and execute the following command:

maven hp:create-portal-project

This generates a basic project structure. If you want to know more about the file structure generated by the Hippo Portal Maven plugin, go to this page .

Change the artifactId value in

c:/projects/gettingstarted-portal/project.xml

from portal-template to gettingstarted.

If you want to use Eclipse for development environment, go to this reference page to learn how to import and configure the new project in Eclipse.

The new project needs to be configured in order to successfully build, deploy and test the portal. This is mainly done through Maven build properties. The Maven build properties must be defined in the file:

c:/projects/gettingstarted-portal/project.properties.

The Hippo Portal plugin creates an example project.properties.template in the same folder describing all these properties.
You can copy/rename that file to project.properties and fill in the values corresponding with your project.

Easier for now is just to copy/paste the minimal configuration needed for our getting-started portal as displayed below:

# Location of the web application, e.g. Tomcat.
nl.hippo.portal.server.home=c:/tomcat-5.5

# Portal Database Settings.
nl.hippo.portal.database.default.name=mysql
nl.hippo.portal.database.url=jdbc:mysql://127.0.0.1:3306/helloWorldPortal
nl.hippo.portal.database.driver=com.mysql.jdbc.Driver
nl.hippo.portal.database.user=root
nl.hippo.portal.database.password=

# The location of the database JDBC driver.
nl.hippo.portal.jdbc.drivers.path=${nl.hippo.portal.server.home}/common/endorsed/mysql-connector-java-5.0.4.jar

Create the project.properties file and adjust the properties values where needed.

For the remainder of the document, it is assumed that the installation dir of Tomcat is c:/tomcat-5.5

Setting up the Hello World Portlet Application

Now, you need to set up the portlet application project, which is, like the portal, based on Hippo Portal components. This portlet application will contain the Hello World Portlet and will be deployed in the Getting Started Portal.

Create a portlet application project

Create a folder on your filesystem for the new project. For the remainder of the document, we assume that you created the folder

c:/projects/hello-world-pa

for this purpose. Let's call this project the "Hello World Portlet Application". Open a console in the folder you just created and execute the following command:

maven hp:create-pa-project

This generates a basic project structure. If you want to know more about the file structure generated by the Hippo Portal Maven plugin, go to this page .

Change the artifactId element value in

c:/projects/hello-world-pa/project.xml to hello-world-pa.

If you want to use Eclipse for development environment, go to this page to learn how to import and configure the new project in Eclipse.

Configuring the Hello World Portlet

We'll configure a portlet that will present content from an XML document in Hippo Repository. You don't need to write any Java code for this. Instead, we are going to use an out-of-the-box portlet which comes with Hippo Portal called the "XSLTContentPortlet". This portlet takes an XML document from Hippo Repository as input and renders the view with an XSLT stylesheet. To configure this portlet, follow the steps outlined below.

  • To define the HelloWorldPortlet, having an XSLT stylesheet as preference parameter, edit file

    c:/projects/hello-world-pa/src/webapp/WEB-INF/portlet.xml

    and replace the contents of this file with the following XML:
<portlet-app
  xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
  version="1.0">

  <portlet>
    <portlet-name>HelloWorldPortlet</portlet-name>
    <portlet-class>nl.hippo.portal.cms.portlets.XSLTContentPortlet</portlet-class>
    <supports>
      <mime-type>text/html</mime-type>
    </supports>
    <portlet-info>
      <title>Hello World Portlet</title>
    </portlet-info>
    <portlet-preferences>
      <preference>
        <name>xslt</name>
        <value>/WEB-INF/xslt/helloWorld.xslt</value>
      </preference>
    </portlet-preferences>
  </portlet>

</portlet-app>
  • To define the XSLT stylesheet, create file

    c:/projects/hello-world-pa/src/webapp/WEB-INF/xslt/helloWorld.xslt

    with the following content:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="/">
    <!-- the title of the document -->
    <h2><xsl:value-of select="/root/title"/></h2>
    <!-- the HTML content of the document -->
    <p>
      <xsl:copy-of select="/root/body/html/body/node()"/>
    </p>
  </xsl:template>

</xsl:stylesheet>

The xslt code above will transform a simple XML document to a HTML snippet, which will be the output of the portlet.

Defining the page in the portal

Now back to the Getting Started Portal to define a page for the portal with two portlets on it: the Hello World portlet plus an example Pick A Number portlet.

The PickANumberPortlet is provided by the Demo portlet application from the Apache Jetspeed-2 Portal (which Hippo Portal is based upon). It is a simple game portlet which repeatedly asks you to guess a number, until you get it right.

In the new portal project, edit the following file:

c:/projects/gettingstarted-portal/src/webapp/WEB-INF/pages/__site1/home.psml

and add two new portlet fragment definitions inside the "home" fragment definition, resulting in the following definition (which you can copy/paste):

<fragment id="home" type="layout" name="jetspeed-layouts::SimpleLayout">
  <preference name="ViewPage"><value>fixed-layout</value></preference>
  <preference name="layoutType"><value>default</value></preference>
  <!--
    add page fragments for home page
  -->
  <fragment id="home-HelloWorld" type="portlet" name="hello-world-pa::HelloWorldPortlet"/>
  <fragment id="home-PickANumberPortlet" type="portlet" name="demo::PickANumberPortlet"/>
</fragment>

These fragments in the home.psml file define the portlet fragments (windows) to be aggregated on the page.

This home page uses a default generic layout that will present the portlets below each other. To change this layout into a dedicated fixed layout, have a look at home page layout .

Building and deploying the portal and the portlet applications

There are now three web applications which need to be built and/or deployed:

  • The Getting Started Portal
  • The Hello World Portlet Application containing our Hello World portlet
  • The Demo Portlet Application (from the Apache Jetspeed-2 Portal) containing the Pick A Number portlet

The Getting Started Portal Application

First we build and deploy the Getting Started Portal. From the root folder of the Getting Started Portal project, execute the following commands after each other:

maven hp:build-portal
maven hp:init-portal-db
maven hp:deploy-portal
        

The Hello World Portlet Application

From the root folder of the Hello World Portlet Application project, execute the following command:

maven clean war

and copy

c:/projects/hello-world-pa/target/hello-world-pa.war

to

c:/tomcat-5.5/webapps/gettingstarted/WEB-INF/deploy

Every portlet application running on Jetspeed has to be deployed via the deploy folder. Jetspeed needs to register every portlet application internally, in order to invoke portlets.

The Demo Portlet Application

First download the Jetspeed Demo portlet application (right-click the link and select Save as..). Rename the file to "demo.war" and copy the renamed file to

c:/tomcat-5.5/webapps/gettingstarted/WEB-INF/deploy

Admire the end result

Congratulations! You have just built your first Portal page containing two portlets. Time to admire the result! First, make sure you have the repository running at http://localhost:60000/default as described in required components .

Using your console, go to

c:/tomcat-5.5/bin

and execute:

startup

Wait until you have seen at least the following messages on the console:

INFO: Server startup in XXX ms
JetspeedContainerServlet: initialization done for Portlet Application at: demo
JetspeedContainerServlet: initialization done for Portlet Application at: hello-world-pa
        

Go to http://localhost:8080/gettingstarted in your browser to view the result.

Using the CMS to change content

Now for the finale, go to your CMS in another browser at http://localhost:50000/ (if you haven't done already, for details see component applications ). Now navigate to Documents (middle top tab) and in the left tree open the node root/documents/example. Select the document named helloworld and open the document editor using the workflow box on the right side, item Edit document

Change the text into, for example, Hello Hippo! and save the document.

Go to the your browser pointing at your portal and refresh the page to see that the content text has changed! Congratulations and thank you for using Hippo Portal!