jsf2-hello-world-portlet: JSF2 Hello World Portlet

Author: Peter Palaga, Brian Leathem, Ken Finnigan
Level: Beginner
Technologies: JSF2, Portlet Bridge
Summary: A simple portlet using JavaServer Faces 2.
Target Product: JBoss Portal
Source: https://github.com/jboss-developer/jboss-portal-quickstarts.git

What is it?

This project demonstrates how to create a simple portlet using JavaServer Faces 2.1 and Portlet Bridge 3.3.1.Final.

An introduction and some background information to this quickstart can be found in the following chapters of Red Hat JBoss Portal Developer Guide:

System Requirements

All you need to build this example project is Java 6.0 (Java SDK 1.6) or newer and Maven 3.0 or newer.

The project is designed to be deployed on Red Hat JBoss Portal 6.1 running on JBoss EAP.

Configure Maven

You have two options how you can configure Maven: A. Use hosted Maven repository or B. Download & setup zipped Maven repository.

A. Use hosted Maven repository

This is the easier and thus recommended option. You need to configure the Maven user settings as follows:

B. Download & setup zipped Maven repositories

  1. Download the following zipped Maven repositories from Red Hat Customer Portal, Downloads > JBoss Enterprise Middleware:

    Unpack each of these files to a separate directory.

  2. Modify the settings-zipped-repos.xml file located in the root directory of Red Hat JBoss Portal quickstarts:

  3. Configure the Maven user settings.

Start the Portal

  1. Open a command line and navigate to the root of the JBoss server directory.
  2. The following shows the command line to start the server with the web profile:

    For Linux:   JBOSS_HOME/bin/standalone.sh
    For Windows: JBOSS_HOME\bin\standalone.bat
    

Build and Deploy the Quickstart

  1. Make sure you have started the Portal as described above.
  2. Open a command line and navigate to the root directory of this quickstart.
  3. Type this command to build and deploy the archive:

    mvn clean package jboss-as:deploy
    

    To deploy to other than default localhost:9999 JBoss instance, copy the following configuration just after <artifactId>jboss-as-maven-plugin</artifactId> in the pom.xml file and adjust it to suit your needs. username and password elements can be omitted sometimes, depending on your JBoss security settings.

    <configuration>
        <hostname>127.0.0.1</hostname>
        <port>9999</port>
        <username>admin</username>
        <password>secret</password>
    </configuration>
    

    This will deploy target/jsf2-hello-world-portlet.war to the running instance of the portal.

Access the deployed Portlet

To ensure that the example portlet has been deployed successfully, do the following:

Undeploy the Archive

  1. Make sure you have started the JBoss Server as described above.
  2. Open a command line and navigate to the root directory of this quickstart.
  3. When you are finished testing, type this command to undeploy the archive:

    mvn jboss-as:undeploy
    

Use JBoss Developer Studio or Eclipse with JBoss Tools to Run this Quickstart

You can also deploy the quickstarts from Eclipse using JBoss Tools. For more information on how to set up Maven and JBoss Tools, refer to the JBoss Enterprise Application Platform 6 Development Guide or Get Started Developing Applications.

Debug the Application

If you want to debug the source code or look at the Javadocs of any library in the project, run either of the following commands to pull them into your local repository. The IDE should then detect them.

mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc

Feedback

Please post feedback on this quickstart or Red Hat JBoss Portal on Online User Group.