JBoss Portal 2.6.2

Reference Guide

Thomas Heute

Julien Viet

Roy Russo

Release 2.6.2

October 2007


Table of Contents

JBoss Portal - Overview
Feature List
Target Audience
Acknowledgements
1. System Requirements
1.1. Minimum System Requirements
1.2. Supported Operating Systems
1.3. JBoss Application Server
1.4. Database
1.5. Source building
2. Installation
2.1. Installing from Bundled Download
2.1.1. Installing the Bundle
2.2. Installing from Binary Download
2.2.1. Setting up your environment
2.2.1.1. Getting the Binary
2.2.1.2. Application Server Setup
2.2.1.3. Database Setup
2.2.1.4. DataSource Configuration
2.2.2. Deploying JBoss Portal
2.3. Installing from Sources
2.3.1. Getting the Sources
2.3.2. Setting up the application server
2.3.2.1. Application Server Setup
2.3.2.2. Operating System Environment Setting
2.3.3. Building/Deploying from Sources
2.3.4. Setting up the database
2.3.4.1. Database Setup
2.3.4.2. DataSource Configuration
2.3.5. Starting and running JBoss Portal
3. Customizing your installation
3.1. Changing the port
3.2. Changing the context path
3.3. Forcing the DB dialect
3.3.1. DB Dialect settings for the portal core
3.3.2. DB Dialect settings for the CMS component
3.4. Setting up the email service
3.5. Setting up proxy settings
3.6. Disabling dynamic proxy unwrapping
4. Upgrading 2.4 - 2.6
4.1. Manual upgrade
4.1.1. Theme
4.1.2. Database
4.1.2.1. Portlet names
4.1.2.2. CMS
5. Portlet Primer
5.1. JSR-168 Overview
5.1.1. Portal Pages
5.1.2. Rendering Modes
5.1.3. Window States
5.1.4. Section Status
5.2. Tutorials
5.2.1. Deploying your first portlet
5.2.1.1. Introduction
5.2.1.2. Package Structure
5.2.1.3. Portlet Class
5.2.1.4. Application Descriptors
5.2.1.5. Building your portlet
5.2.1.6. Deploying your portlet
5.2.2. A Simple JSP Portlet
5.2.2.1. Introduction
5.2.2.2. Package content
5.2.2.3. Portlet Class
5.2.2.4. JSP files and the portlet taglib
5.2.2.5. Building and deploying your portlet
5.2.3. A simple Sun's JSF Reference Implementation (RI) portlet on JBoss AS 4.2.x
5.2.3.1. Introduction
5.2.3.2. Package Content
5.2.3.3. Building and deploying your portlet
5.2.4. A simple MyFaces JSF Portlet on JBoss AS 4.0.5+
5.2.4.1. Introduction
5.2.4.2. Package Content
5.2.4.3. Building and deploying your portlet
5.2.5. Adapting MyFaces JSF Portlet to work on JBoss AS 4.2.x
6. XML Descriptors
6.1. Changes since previous releases
6.1.1. JBoss Portlet DTD
6.1.2. Portlet Instance DTD
6.1.3. Portal Object DTD
6.1.4. JBoss App DTD
6.2. Portlet Descriptors
6.2.1. *-object.xml
6.2.2. portlet-instances.xml
6.2.3. jboss-portlet.xml
6.2.3.1. Injecting Header Content
6.2.3.2. Injecting Services in the portlet context
6.2.3.3. Portlet Session Replication in a Clustered Environment
6.2.4. portlet.xml
6.3. JBoss Portal Descriptors
6.3.1. Datasource Descriptor (portal-*-ds.xml)
6.3.1.1. Obtaining Datasource Descriptors Binary releases
6.3.1.2. Building Datasource Descriptors from Source
6.3.2. Portlet Debugging (jboss-portal.sar/conf/config.xml)
6.3.3. Login to dashboard
6.4. Descriptor Examples
6.4.1. Defining a new portal page
6.4.2. Defining a new portal instance
7. Portal urls
7.1. Introduction
7.2. Accessing a portal
7.3. Accessing a page
7.4. Accessing CMS Content
8. Error handling configuration
8.1. Error types
8.2. Control policies
8.2.1. Policy delegation and cascading
8.2.2. Default policy
8.2.3. Portal policy
8.2.4. Page policy
8.3. Configuration using the XML descriptors
8.3.1. Portal policy properties
8.3.2. Page policy properties
8.4. Handling errors with JSP
8.5. Configuration using the Portal Management Application
9. Content Integration
9.1. Window content
9.2. Content customization
9.3. Content Driven Portlet
9.3.1. Displaying content
9.3.2. Configuring content
9.3.3. Step by step example of a content driven portlet
9.3.3.1. The Portlet skeleton
9.3.3.2. Overriding the dispatch method
9.3.3.3. Utilities methods
9.3.3.4. The editor
9.3.3.5. Viewing content at runtime
9.3.3.6. Hooking the portlet into the portal
9.4. Configuring window content in deployment descriptor
10. Portlet Modes
10.1. Admin Portlet Mode
10.1.1. Portlet configuration
10.1.2. Declarative instance security configuration
10.1.3. Instance security configuration with the administration portlet
11. Portal API
11.1. Introduction
11.2. Portal URL
11.3. Portal session
11.4. Portal runtime context
11.5. Portal nodes
11.6. Portal navigational state
11.7. Portal events
11.7.1. Portal node events
11.7.1.1. Portal node event propagation model
11.7.1.2. Portal node event listener
11.7.1.3. Portal node event context
11.7.2. Portal session events
11.7.3. Portal user events
11.8. Examples
11.8.1. UserAuthenticationEvent example
11.8.2. Achieving Inter Portlet Communication with the events mechanism
11.8.3. Link to other pages
12. Clustering Configuration
12.1. Introduction
12.2. Considerations
12.3. JBoss Portal Clustered Services
12.3.1. Portal Session Replication
12.3.2. Hibernate clustering
12.3.3. Identity clustering
12.3.4. CMS clustering
12.4. Setup
12.5. Portlet Session Replication
12.5.1. JBoss Portal configuration
12.5.2. Portlet configuration
12.5.3. Limitations
13. Web Services for Remote Portlets (WSRP)
13.1. Introduction
13.2. Level of support in JBoss Portal
13.3. Deploying JBoss Portal's WSRP services
13.3.1. Considerations to use WSRP behind firewall
13.3.2. Considerations to use WSRP when running Portal on a non-default port
13.3.3. Considerations to use WSRP with SSL
13.4. Making a portlet remotable
13.5. Consuming JBoss Portal's WSRP portlets from a remote Consumer
13.6. Consuming remote WSRP portlets in JBoss Portal
13.6.1. Overview
13.6.2. Configuring a remote producer walk-through
13.6.2.1. Using a WSRP Producer XML descriptor
13.6.2.2. Using the configuration portlet
13.6.2.3. Configuring access to a remote portlet
13.6.3. WSRP Producer descriptors
13.6.3.1. Required configuration information
13.6.3.2. Optional configuration
13.6.4. Examples
13.7. Configuring JBoss Portal's WSRP Producer
13.7.1. Overview
13.7.2. Default configuration
13.7.3. Minimal producer configuration
13.7.4. Registration configuration
13.7.4.1. Customization of Registration handling behavior
13.7.4.2. Registration properties
13.7.5. Example
14. Security
14.1. Securing Portal Objects
14.2. Securing the Content Management System
14.2.1. CMS Security Configuration
14.3. Authentication with JBoss Portal
14.3.1. Authentication configuration
14.3.2. The portal servlet
14.4. Authorization with JBoss Portal
14.4.1. The portal permission
14.4.2. The authorization provider
14.4.3. Making a programmatic security check
14.4.4. Configuring an authorization domain
15. JBoss Portal Identity Management
15.1. Identity management API
15.1.1. How to obtain identity modules services ?
15.1.2. API changes since 2.4
15.2. Identity configuration
15.2.1. Main configuration file architecture (identity-config.xml)
15.2.1.1. Datasources
15.2.1.2. Modules
15.2.1.3. Options
15.3. User profile configuration
15.4. Identity modules implementations
15.4.1. Database modules
15.4.2. Delegating UserProfile module
15.4.3. Database UserProfile module implementation
16. JBoss Portal Identity Portlets
16.1. Introduction
16.1.1. Features
16.2. Configuration
16.2.1. Captcha support
16.2.2. Lost password
16.2.3. Reset password
16.2.4. jBPM based user registration
16.2.5. The configuration file
16.2.6. Customize e-mail templates
16.3. User interface customization
16.3.1. Example 1: required fields
16.3.2. Example 2: dynamic values (dropdown menu with predefined values)
16.3.3. Example 3: adding new properties
16.3.4. Illustration
16.3.5. Customizing the View Profile page
16.4. Customizing the workflow
16.4.1. Duration of process validity
16.5. Disabling the Identity Portlets
16.5.1. Enabling the Identity Portlets
17. Authentication and Authorization
17.1. Authentication in JBoss Portal
17.1.1. Configuration
17.2. JAAS Login Modules
17.2.1. org.jboss.portal.identity.auth.IdentityLoginModule
17.2.2. org.jboss.portal.identity.auth.DBIdentityLoginModule
17.2.3. org.jboss.portal.identity.auth.SynchronizingLdapLoginModule
17.2.4. org.jboss.portal.identity.auth.SynchronizingLdapExtLoginModule
17.2.5. org.jboss.portal.identity.auth.SynchronizingLoginModule
18. LDAP
18.1. How to enable LDAP usage in JBoss Portal
18.2. Configuration of LDAP connection
18.2.1. SSL
18.2.2. ExternalContext
18.3. LDAP Identity Modules
18.3.1. Common settings
18.3.2. UserModule
18.3.2.1. LDAPUserModuleImpl
18.3.2.2. LDAPExtUserModuleImpl
18.3.3. RoleModule
18.3.3.1. LDAPRoleModuleImpl
18.3.3.2. LDAPExtRoleModuleImpl
18.3.4. MembershipModule
18.3.4.1. LDAPStaticGroupMembershipModuleImpl
18.3.4.2. LDAPStaticRoleMembershipModuleImpl
18.3.5. UserProfileModule
18.3.5.1. LDAPUserProfileModuleImpl
18.4. LDAP server tree shapes
18.4.1. Keeping users membership in role entries
18.4.1.1. Example LDIF
18.4.1.2. Example identity configuration
18.4.2. Keeping users membership in user entries
18.4.2.1. Example LDIF
18.4.2.2. Example identity configuration
18.5. Synchronizing LDAP configuration
18.6. Supported LDAP servers
19. Single Sign ON
19.1. Overview of SSO in portal
19.2. Using Tomcat Valve
19.2.1. Enabling Tomcat SSO Valve
19.2.2. Example of usage
19.3. CAS - Central Authentication Service
19.3.1. Integration steps
19.4. JOSSO - Java Open Single SignOn
19.4.1. Integration steps
20. CMS Portlet
20.1. Introduction
20.2. Features
20.3. CMS content
20.3.1. Configuring a window to display CMS content
20.4. CMS Configuration
20.4.1. Display CMS content
20.4.2. Service Configuration
20.4.2.1. Tuning Jackrabbit
20.4.2.2. Changing the url under which the content should be accessible
20.4.3. Configuring the Content Store Location
20.4.3.1. 100% Filesystem Storage
20.4.3.2. 100% Database Storage
20.4.3.3. Mixed Storage
20.5. Localization Support
20.6. CMS Service
20.6.1. CMS Interceptors
21. Portal Workflow
21.1. JBPM Workflow Engine Integration
21.2. CMS Publish/Approve Workflow Service
22. Navigation Tabs
22.1. Explicit ordering of tabs
22.2. Internationalizing tab labels
23. Layouts and Themes
23.1. Overview
23.2. Header
23.2.1. Overview
23.2.1.1. Writing his own JSPs
23.3. Layouts
23.3.1. How to define a Layout
23.3.2. How to use a Layout
23.3.2.1. Declarative use
23.3.2.2. Programatic use
23.3.3. Where to place the Descriptor files
23.3.4. Layout JSP-tags
23.4. RenderSets
23.4.1. What is a RenderSet
23.4.2. How is a RenderSet defined
23.4.3. How to specify what RenderSet to use
23.5. Themes
23.5.1. What is a Theme
23.5.2. How to define a Theme
23.5.3. How to use a Theme
23.5.4. How to write your own Theme
23.6. Other Theme Functionalities and Features
23.6.1. Content Rewriting and Header Content Injection
23.6.2. Declarative CSS Style injection
23.6.3. Disabling Portlet Decoration
23.7. Theme Style Guide (based on the Industrial theme)
23.7.1. Overview
23.7.2. Main Screen Shot
23.7.3. List of CSS Selectors
23.8. Additional Ajax selectors
24. Ajax
24.1. Introduction
24.2. Ajaxified markup
24.2.1. Ajaxified layouts
24.2.2. Ajaxified renderers
24.3. Ajaxified pages
24.3.1. Drag and Drop
24.3.2. Partial refresh
24.3.2.1. Portal objects configuration
24.3.2.2. Portlet configuration
24.3.2.3. Limitations
25. Troubleshooting and FAQ
25.1. Troubleshooting and FAQ

JBoss Portal - Overview

Many IT organizations look to achieve a competitive advantage for the enterprise by improving business productivity and reducing costs. Today's top enterprises are realizing this goal by deploying enterprise portals within their IT infrastructure. Enterprise portals simplify access to information by providing a single source of interaction with corporate information. Although today's packaged portal frameworks help enterprises launch portals more quickly, only JBoss Portal can deliver the benefits of a zero-cost open source license combined with a flexible and scalable underlying platform.

JBoss Portal provides an open source and standards-based environment for hosting and serving a portal's Web interface, publishing and managing its content, and customizing its experience. It is entirely standards-based and supports the JSR-168 portlet specification, which allows you to easily plug-in standards-compliant portlets to meet your specific portal needs. JBoss Portal is available through the business-friendly LGPL open source license and is supported by Red Hat Middleware, LLC Professional Support and Consulting . JBoss support services are available to assist you in designing, developing, deploying, and ultimately managing your portal environment. JBoss Portal is currently developed by Red Hat Middleware, LLC developers and community contributors.

The JBoss Portal framework and architecture includes the portal container and supports a wide range of features including standard portlets, single sign-on, clustering and internationalization. Portal themes and layouts are configurable. Fine-grained security administration down to portlet permissions rounds out the security model.

JBoss Portal Resources:

The JBoss Portal team encourages you to use this guide to install and configure JBoss Portal. If you encounter any configuration issues or simply want to take part in our community, we would love to hear from you in our forums.

Feature List

The following list details features found in this document's related release. For a technical view of our features, view the Project Roadmap and Task List .

Technology and Architecture

  • JEMS: Leverages the power of JBoss Enterprise Middleware Services : JBoss Application Server, JBoss Cache, JGroups, and Hibernate.
  • DB Agnostic: Will work with any RDBMS supported by Hibernate
  • JAAS Authentication: Custom authentication via JAAS login modules.
  • Cacheing: Utilizes render-view caching for improved performance.
  • Clusterable: Cluster support allows for portal state to be clustered for all portal instances.
  • Hot-Deployment: Leverages JBoss dynamic auto deployment features.
  • SAR Installer: Browser-based installer makes installation and initial configuration a breeze.

Single Sign On

  • Leverages Tomcat and JBoss single sign on (SSO) solutions.
  • Integrates with JOSSO and CAS out of the box. (Experimental support for Open SSO)

LDAP

  • Connect to virtually any LDAP server
  • Integrates with Sun Active Directory and OpenLDAP out of the box. (Experimental support for Active Directory)

Supported Standards

  • Portlet Specification and API 1.0 (JSR-168)
  • Content Repository for Java Technology API (JSR-170)
  • Java Server Faces 1.2 (JSR-252)
  • Java Management Extension (JMX) 1.2
  • Web Services for Remote Portlets (WSRP) 1.0 See WSRP support in Portal for more details.
  • Full J2EE 1.4 compliance when used with JBoss AS

Portal and Portal Container

  • Multiple Portal Instances: Ability to have multiple Portal instances running inside of one Portal container.
  • IPC Inter-Portlet Communication API enables portlets to create links to other objects such as a page, portal or window .
  • Dynamicity The ability for administrators and users to create and destroy objects such as portlets, pages, portals, themes, and layouts at runtime.
  • Internationalization: Ability to use internationalization resource files for every portlet.
  • Pluggable services: Authentication performed by the servlet container and JAAS make it possible to swap the authentication scheme.
  • Page-based Architecture: Allows for the grouping/division of portlets on a per-page basis.
  • Existing Framework support: Portlets utilizing Struts, Spring MVC, Sun JSF-RI, AJAX, or MyFaces are supported.

Themes and Layouts

  • Easily swappable themes/layouts: New themes and layouts containing images can be deployed in WAR archives.
  • Flexible API: Theme and Layout API are designed to separate the business layer from the presentation layer.
  • Per-page layout strategy: Different layouts can be assigned to different pages.

User and Group Functionality

  • User registration/validation: Configurable registration parameters allow for user email validation before activation.
  • Workflow: Ability to define your own jBPM workflow on user registration.
  • User login: Makes use of servlet container authentication.
  • Create/Edit Users: Ability for administrators to create/edit user profiles.
  • Create/Edit Roles: Ability for administrators create/edit roles.
  • Role Assignment: Ability for administrators to assign users to roles.
  • Captcha support: To distinct humans from machines when registering.

Permissions Management

  • Extendable permissions API: Allows custom portlets permissions based on role definition.
  • Administrative interface: Allows for permissions assignments to roles at any time for any deployed portlet, page, or portal instance.

Content Management System

  • JCR-compliant: The CMS is powered by Apache Jackrabbit, an open source implementation of the Java Content Repository API.
  • DB or Filesystem store support: Configurable content store to either a filesystem or RDBMS.
  • External Blob Support: Configurable content store allowing large blobs to reside on filesystem and content node references/properties to reside in RDBMS.
  • Versioning support: All content edited/created is autoversioned with a history of edits that can be viewed at any time.
  • Content Serving Search-engine-friendly URLS: http://yourdomain/portal/content/index.html (Does not apply to portlet actions.)
  • No long portal URLS: Serve binaries with simple urls. (http://domain/files/products.pdf)
  • Multiple HTML Portlet instance support: Allows for extra instances of static content from the CMS to be served under separate windows.
  • Directory Support: create, move, delete, copy, and upload entire directory trees.
  • File Functions: create, move, copy, upload, and delete files.
  • Embedded directory-browser: When copying, moving, deleting, or creating files, administrators can simply navigate the directory tree to find the collection they want to perform the action on.
  • Ease-of-use architecture: All actions to be performed on files and folder are one mouse-click away.
  • Full-featured HTML editor: HTML Editor contains WYSIWYG mode, preview functionality, and HTML source editting mode. HTML commands support tables, fonts, zooming, image and url linking, flash movie support, bulleted and numbered list, and dozens more.
  • Editor style-sheet support: WYSIWYG editor displays current Portal style-sheet, for easy choosing of classes.
  • Internationalization Support: Content can be attributed to a specific locale and then served to the user based on his/her browser settings.
  • Workflow Support: Basic submit for review and approval process.

Target Audience

Portlet developers, Portal administrators, and those wishing to implement/extend the JBoss Portal framework.

For end-user documentation, please download our User Guide from our documentation page .

Acknowledgements

We would like to thank the developers that participate in the JBoss Portal project effort.

Specifically,

  • Antoine Herzog for his feedback, for writing Wikis and helping in the forums.
  • Mark Fernandes and Paul Tamaro from Novell, for their hard work in supplying the portal project with usable and attractive themes and layouts in the 2.4 version of JBoss Portal.
  • Martin Holzner from Novell, for his work on themes in the 2.4 version of JBoss Portal.
  • Kev "kevs3d" Roast for supplying us with two working portlets that integrate existing frameworks in to the portal: Sun JSF-RI and Spring MVC Portlet.
  • Swarn "sdhaliwal" Dhaliwal for supplying us with the Struts-Bridge, that will allow for existing struts applications to work with the Portal.
  • A few Red Hat employees, Remy Maucherat for Tomcat configuration, Magesh Kumar Bojan and Martin Putz always there to help our customers, Prabhat Jha for making sure that JBoss Portal runs great everywhere. Noel Rocher for his early feedback on JBoss Portal 2.6 and contributions. James Cobb for the Renaissance theme.
  • The JBoss Labs (http://www.JBoss.org) team for building a great infrastructure on top of JBoss Portal 2.6, providing very useful feedback and giving us the initial Drag and Drop implementation.
  • Everyone participating in the forums and Wiki in general.

Contributions of any kind are always welcome, you can contribute by providing ideas, filling bug reports, producing some code, designing a theme, writing some documentation, etc... If you think your name is missing from this page, please let us know.

Chapter 1. System Requirements

Thomas Heute

Roy Russo

A list of tested versions or reported as working by users, before reporting a problem please make sure that you are using a compatible version.

If you successfully installed JBoss Portal on versions not listed here please let us know so we can add it here.

1.1. Minimum System Requirements

  • JDK 1.4 or JDK 5 (JDK 6 is not part of the test platform)
  • 512 MB RAM
  • 100 MB hard disk space
  • 400 MHz CPU

Warning

JBoss Portal 2.6.2 is the last release to support JDK 1.4.

1.2. Supported Operating Systems

JBoss Portal is 100% pure Java and therefore interoperable with most operating systems capable of running a Java Virtual Machine (JVM); including Linux, Windows, UNIX, MacOS X.

1.3. JBoss Application Server

JBoss Portal 2.6.2 is tested with JBoss AS 4.0.5, JBoss AS 4.2.1 and JBoss EAP 4.2. It is highly recommended to use JBoss Portal 2.6.2 with JBoss Enterprise Application Platform 4.2 for customers who have access to it through the support portal and JBoss AS 4.2.1 for everybody else.

Warning

Versions before 4.0.4 of JBoss Application Server are not supported with this version of JBoss Portal. And JBoss AS 4.0.5 will not be supported in newer release of JBoss Portal.

1.4. Database

JBoss Portal is Database-Agnostic.

Note

JBoss Portal employs Hibernate as an interface to RDBMS. Most RDBMS supported by Hibernate will work with JBoss Portal.

The following list, outlines known-to-be-working database vendor and version combinations:

  • MySQL 4.x.x (along with the connector 3.0.16)
  • MySQL 5 ( known issue )
  • PostgreSQL 8.x
  • HypersonicSQL
  • Derby
  • Oracle 9 and 10g (make sure to use the latest driver of Oracle's 10 branch even when running Oracle 9)
  • Microsoft SQL Server
  • MaxDB

1.5. Source building

The source building mechanism works on Linux, Windows, MacOS X and any 'Unix like' operating system.

Chapter 2. Installation

Depending on your needs, there are several different methods to get JBoss Portal up and running.

Note

Pre-configured clustered versions are available from the download page , in the same 3 flavors as the non-clustered version. The installation differences, being that they must be deployed in the all configuration in JBoss AS and all your instances must reference the same datasource. Read Chapter 12, Clustering Configuration for more details on how to customize your clustered install, once deployed.

Installation of JBoss Portal on former version of JBoss AS

If you need to install JBoss Portal on JBoss AS 4.0.x, please refer to the dedicated wiki page.

2.1. Installing from Bundled Download

This is the easiest and fastest way to get JBoss Portal installed and running. The reason, is that the download bundle contains JBoss Application Server, and JBoss Portal uses the embedded Hypersonic Database.

2.1.1. Installing the Bundle

  • Get the Bundle: The download bundle is available from our download page . Bundles are noted with the 'JBoss Portal + AS' naming convention.

  • Extract the bundle: Extract the zip archive to a directory of your choosing. In windows, we recommend, C:\jboss-X.X.X

  • Start the Server: Go to JBOSS_INSTALL_DIRECTORY/bin and execute run.bat (run.sh, if Linux)

Note

During the first boot (ever), SQL errors in the log, like the one below, can be safely ignored. They are thrown when the portal checks for the existence of the initial tables, before it creates them for you.
16:43:39,234 WARN [JDBCExceptionReporter] SQL Error: -22, SQLState: S0002
16:43:39,234 ERROR [JDBCExceptionReporter] Table not found in statement ...

Point your browser to http://localhost:8080/portal , and you should see the Portal HomePage. You can now login using one of the two default accounts: user/user or admin/admin .

2.2. Installing from Binary Download

The binary download package typically consists of the jboss-portal.sar , documentation (which you are already reading), and a set of preconfigured datasource descriptors that allow JBoss Portal to communicate with a database.

This installation method is preferred by those who already have JBoss Application Server installed or those we need to install the version ready for clustering.

2.2.1. Setting up your environment

2.2.1.1. Getting the Binary

The binary download is available from our download page .

Once downloaded and extracted, the folder hierarchy should look like this:

We will be using files contained in this download in the further sections, so please download and extract it first.

2.2.1.2. Application Server Setup

Of course you will need to install JBoss Application Server prior to installing JBoss portal, if you didn't do so yet, please install JBoss EAP 4.2 or JBoss AS 4.2.1. If you have a subscription contract with Red Hat, can have access to the EAP version from the support portal. For the other versions you can get them here .

Warning

Make sure to download the JBoss AS Zip version. DO NOT ATTEMPT to deploy JBoss Portal on the installer version of JBoss AS! We are currently working on aligning the Application installer with JBoss Portal.

2.2.1.3. Database Setup

You will need a database for JBoss Portal to run, you can use any database supported by Hibernate.

  1. Create a new Database: For example purposes we call this new database jbossportal

  2. Grant access rights for a user to your database: You must make sure the user has access to this new DB, as JBoss Portal will need to create the tables and modify data within them.

  3. Deploy your JDBC connector: You must make available a JDBC connector for JBoss Portal to communicate with your database. The connector lib should be placed in JBOSS_INSTALL_DIRECTORY/server/default/lib/*

2.2.1.4. DataSource Configuration

The JBoss Portal download you extracted in Section 2.2.1.1, “Getting the Binary” contains pre-configured datasource descriptors, you can use for most popular RDBMS under the setup directory. For more details about the datasource descriptor or if your database server is not part of the pre-built descriptors, please refer to: the dedicated wiki page.

At this point, you should configure the one that suits you best with your Database and JDBC driver.

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
  <local-tx-datasource>
    <jndi-name>PortalDS</jndi-name>
    <connection-url>jdbc:postgresql:jbossportal</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <user-name>portal</user-name>
    <password>portalpassword</password>
  </local-tx-datasource>
</datasources>
                  

Please verify that the username, password, url, and driver-class are correct for your flavor of DB. You can deploy the datasource file by itself to test, in advance.

2.2.2. Deploying JBoss Portal

  1. Deploy: Copy the datasource descriptor file (*-ds.xml) you modified above AND the jboss-portal.sar from the download folder to JBOSS_INSTALL_DIRECTORY/server/default/deploy/.

  2. Start the Server: Go to JBOSS_INSTALL_DIRECTORY/bin and execute run.bat (run.sh, if Linux)

Note

During the first boot (ever), SQL errors in the log, like the one below, can be safely ignored. They are thrown when the portal checks for the existence of the initial tables, before it creates them for you.
16:43:39,234 WARN [JDBCExceptionReporter] SQL Error: -22, SQLState: S0002
16:43:39,234 ERROR [JDBCExceptionReporter] Table not found in statement ...

Point your browser to http://localhost:8080/portal , and you should see the Portal HomePage. You can now login using one of the two default accounts: user/user or admin/admin .

2.3. Installing from Sources

2.3.1. Getting the Sources

There are two ways for you to obtain the JBoss Portal source files:

  • From our download page

  • From SVN, using the following URL:

    • http://anonsvn.jboss.org/repos/portal/branches/JBoss_Portal_Branch_2_6 : For the latest sources of the 2.6 branch
    • http://anonsvn.jboss.org/repos/portal/trunk/ : For the latest sources

    Note

    For more information on Portal SVN, and accessing different versions of the Portal codebase, please visit this wiki article.

After checking out of SVN or extracting the Source zip, your directory structure should look like this:

Note

The screenshot above, shows the downloaded source directory. Those of you checking out from SVN, will get an empty thirdparty directory. This directory will be filled when you first run the build in the following steps.

2.3.2. Setting up the application server

2.3.2.1. Application Server Setup

Of course you will need to install JBoss Application Server prior to installing JBoss portal, if you didn't do so yet, please install JBoss EAP 4.2 or JBoss AS 4.2.1. If you have a subscription contract with Red Hat, can have access to the EAP version from the support portal. For the other versions you can get them here .

2.3.2.2. Operating System Environment Setting

For the build targets to work, you must first set the JBOSS_HOME environment variable in your operating system, to the root directory of the JBoss Application Server installation.

In Windows, this is accomplished by going to Start > Settings > Control Panel > System > Advanced > Environment Variables . Now under the System Variables section, click New . You will be setting the JBOSS_HOME environment variable to the location of your JBoss Application Server installation:

On a Unix-like Operating System, you would accomplish this by typing: export JBOSS_HOME=/path/to/your/jboss/directory

2.3.3. Building/Deploying from Sources

To build and deploy the JBoss Portal service, go to JBOSS_PORTAL_HOME_DIRECTORY/build and type:

build deploy

Note

During the first compilation, third-party libraries will be obtained from an online repository, you need to be connected to Internet and if you are behind a proxy, you also need to define your proxy address and host by adding: JAVA_OPTS=-Dhttp.proxyHost=<Proxy Host> -Dhttp.proxyPort=<Proxy Port> in your environment.

Note

To build the clustered version, you will need to go to JBOSS_PORTAL_HOME_DIRECTORY/build and type: build main Then, go to JBOSS_PORTAL_HOME_DIRECTORY/core and type: build deploy-ha This will copy the jboss-portal-ha.sar to your all configuration for you.

At the end of the build process, the jboss-portal.sar is copied to JBOSS_HOME/server/default/deploy.

2.3.4. Setting up the database

2.3.4.1. Database Setup

You will need a database for JBoss Portal to function, you can use any database supported by Hibernate.

  1. Create a new Database: For example purposes we call this new database jbossportal

  2. Grant access rights for a user to your database: You must make sure the user has access to this new DB, as JBoss Portal will need to create the tables and modify data within them.

  3. Deploy your JDBC connector: You must make available a JDBC connector for JBoss Portal to communicate with your database. The connector lib should be placed in JBOSS_HOME/server/default/lib/*

2.3.4.2. DataSource Configuration

You will need a valid datasource descriptor, for JBoss Portal to communicate with your database. Having obtained the sources and having set your JBOSS_HOME environment variable ( Section 2.3.2.2, “Operating System Environment Setting” ), you can now have the JBoss Portal build system generate preconfigured datasources for you.

Navigate to JBOSS_PORTAL_HOME_DIRECTORY/core and type:

build datasource

Once complete, the datasource build should produce the following directory and file structure:

At this point, you should configure the one that suits you best with your Database and JDBC driver.

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
  <local-tx-datasource>
    <jndi-name>PortalDS</jndi-name>
    <connection-url>jdbc:postgresql:jbossportal</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <user-name>portal</user-name>
    <password>portalpassword</password>
  </local-tx-datasource>
</datasources>
                  

Please verify that the username, password, url, and driver-class are correct for your flavor of DB.

Now copy your datasource descriptor to JBOSS_HOME/server/default/deploy

2.3.5. Starting and running JBoss Portal

Start the Server: Go to JBOSS_HOME/bin and execute run.bat (run.sh, if Linux)

Note

During the first boot (ever), SQL errors in the log, like the one below, can be safely ignored. They are thrown when the portal checks for the existence of the initial tables, before it creates them for you.
16:43:39,234 WARN [JDBCExceptionReporter] SQL Error: -22, SQLState: S0002
16:43:39,234 ERROR [JDBCExceptionReporter] Table not found in statement ...

Point your browser to http://localhost:8080/portal , and you should see the Portal HomePage. You can now login using one of the two default accounts: user/user or admin/admin .

Note

This installs a bare version of Portal. In previous versions, several additional modules were deployed as well but this has since been modularized to provide greater flexibility. You might want to deploy additional modules to augment Portal (see Portal's module list for more information). You can also deploy all the modules all at once using build deploy-all in the build directory.

Chapter 3. Customizing your installation

Thomas Heute

This section is intended to describe some customization features available in JBoss Portal. If it is not covered here, please view the FAQ chapter at the end of this document or the descriptor chapter ( Section 6.3, “JBoss Portal Descriptors” ) for further documentation on configuration and tuning JBoss Portal.

3.1. Changing the port

It is common to have a server running on the port 80 instead of the default port 8080.

It might be easier to use port forwarding than to change the port manually. Since port forwarding is not always possible, below are the instructions to change the port number manually.

To change it, you need to edit the file $JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar/server.xml and change the port value of the HTTP Connector. You can also change the value of the SSL port, by default it is set to 8443. Remember to uncomment the following when you have configured it:

            
      <!-- SSL/TLS Connector configuration using the admin devl guide keystore
      <Connector port="8443" address="${jboss.bind.address}"
           maxThreads="100" strategy="ms" maxHttpHeaderSize="8192"
           emptySessionPath="true"
           scheme="https" secure="true" clientAuth="false"
           keystoreFile="${jboss.server.home.dir}/conf/chap8.keystore"
           keystorePass="rmi+ssl" sslProtocol = "TLS" />
      -->
            
         

Please refer to Section 13.3.2, “Considerations to use WSRP when running Portal on a non-default port” to update the WSRP after having changed the port.

Now you can restart JBoss and use the new port that you defined. On systems like Linux, you need privileges to be able to run a server on a port lower than 1000, starting JBoss on the port 80 as a regular user will not work, for testing you can log as root but is not recommended if the server is public as it could be a security breach in your system.

3.2. Changing the context path

By default, the "main" page of JBoss portal will be accessible at http://localhost:8080/portal/index.html . You may want to change that either to a different name or to http://localhost:8080/index.html .

Note

By default, Tomcat holds on to the root context '/'. You may need to either remove the $JBOSS_HOME\server\default\deploy\jbossweb-tomcat55.sar\ROOT.war or add a jboss-web.xml (declaring another context-root other than '/')under its WEB-INFO directory for the below changes to take effect on restart.

You can accomplish this, with either a deployed jboss-portal.sar or before you build from source:

  • Binary method:

    1. Open JBOSS_INSTALL_DIRECTORY/server/default/deploy/jboss-portal.sar/portal-server.war/WEB-INF/jboss-web.xml

      <?xml version="1.0"?>
      <jboss-web>
         <security-domain>java:jaas/portal</security-domain>
         <context-root>/portal</context-root>
         <replication-config>
            <replication-trigger>SET_AND_GET</replication-trigger>
            <replication-type>SYNC</replication-type>
         </replication-config>
         <resource-ref>
            <res-ref-name>jdbc/PortalDS</res-ref-name>
            <jndi-name>java:PortalDS</jndi-name>
         </resource-ref>
      </jboss-web>

    2. Edit the context-root element to whatever you desire.

      <context-root>/</context-root>

  • Source method: Edit the file $PORTAL_HOME/build/local.properties (You can copy the file $PORTAL_HOME/build/etc/local.properties-example and modify it for your own settings.) and change portal.web.context-root to anything you want.

    Now clean the project (ant clean) then build JBoss portal (ant) and redeploy it for the context path changes to take effect. For build instructions, please see: Section 2.3, “Installing from Sources”

3.3. Forcing the DB dialect

If you encounter that the Hibernate dialect is not working properly and would like to override the default behaviour, follow the instructions contained in this section:

Note

Under most common circumstances, the auto-detect feature should work fine.

3.3.1. DB Dialect settings for the portal core

Modify jboss-portal.sar/conf/hibernate/[module]/hibernate.cfg.xml . A list of supported dialects for Hibernate3, can be found here .

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:PortalDS</property>
<property name="show_sql">false</property>
<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="cache.use_query_cache">true</property>

<!-- Force the dialect instead of using autodetection -->
<!--
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
-->

<!-- Mapping files -->
<mapping resource="conf/hibernate/user/domain.hbm.xml"/>
</session-factory>
</hibernate-configuration>               
               

3.3.2. DB Dialect settings for the CMS component

Modify jboss-portal.sar/portal-cms.sar/conf/hibernate/cms/hibernate.cfg.xml . A list of supported dialects for Hibernate3, can be found here .

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>
      <property name="connection.datasource">java:@portal.datasource.name@</property>
      <property name="show_sql">@portal.sql.show@</property>
      <property name="cache.use_second_level_cache">false</property>
      <property name="cache.use_query_cache">true</property>

      <!-- Force the dialect instead of using autodetection -->
      <!--
      <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
      -->

      <!-- Mapping files -->
      <mapping resource="conf/hibernate/cms/domain.hbm.xml"/>
   </session-factory>
</hibernate-configuration>

3.4. Setting up the email service

To be able to use the email service (for example to verify user emails when someone subscribes or for CMS workflow notifications) it has to be configured correctly. To configure it, go to jboss-portal.sar/portal-core.sar/META-INF/jboss-service.xml. In this file, the mail module is configured like this:

<mbean
      code="org.jboss.portal.core.impl.mail.MailModuleImpl"
      name="portal:service=Module,type=Mail"
      xmbean-dd=""
      xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
      <xmbean/>
      <depends>jboss:service=Mail</depends>
      <depends>portal:service=Module,type=IdentityServiceController</depends>
      <attribute name="QueueCapacity">-1</attribute>
      <attribute name="Gateway">localhost</attribute>
      <attribute name="SmtpUser"></attribute>
      <attribute name="SmtpPassword"></attribute>
      <attribute name="JavaMailDebugEnabled">false</attribute>
      <attribute name="SMTPConnectionTimeout">100000</attribute>
      <attribute name="SMTPTimeout">10000</attribute>
      <attribute name="JNDIName">java:portal/MailModule</attribute>
</mbean>

Here you can specify a different SMTP server than localhost, then precise the Smtp username and Smtp passwords to use to send the mails.

If i wanted to use GMail smtp server, i would write:

<mbean
      code="org.jboss.portal.core.impl.mail.MailModuleImpl"
      name="portal:service=Module,type=Mail"
      xmbean-dd=""
      xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
      <xmbean/>
      <depends>jboss:service=Mail</depends>
      <depends>portal:service=Module,type=IdentityServiceController</depends>
      <attribute name="QueueCapacity">-1</attribute>
      <attribute name="Gateway">smtp.gmail.com</attribute>
      <attribute name="SmtpUser">username@gmail.com</attribute>
      <attribute name="SmtpPassword">myPassword</attribute>
      <attribute name="JavaMailDebugEnabled">false</attribute>
      <attribute name="SMTPConnectionTimeout">100000</attribute>
      <attribute name="SMTPTimeout">10000</attribute>
      <attribute name="JNDIName">java:portal/MailModule</attribute>
</mbean>

Note

If you have a 'standard' setup and a mail server installed (That's the case on most Linux distribution out of the box), it will work out of the box.

3.5. Setting up proxy settings

There are a couple of scenarios where you will need your proxy to be correctly defined at the JVM level so that you can access documents from Internet. It could be to get the thirdparty libraries if you decided to build JBoss Portal from the sources, to access RSS feeds or weather information in the samples portlet we provide or for your own needs.

To set up the proxy settings you will need to know the proxy host and the port to use then add them when starting java.

Usually setting up JAVA_OPTS environment variable to -Dhttp.proxyHost=YOUR_PROXY_HOST -Dhttp.proxyPort=YOUR_PROXY_PORT is enough.

3.6. Disabling dynamic proxy unwrapping

JBoss Portal use the JBoss Microkernel for the service infrastructure. The JBoss Microkernel provides injection of services into other services, also known as wiring. Unfortunately it is only possible to inject dynamic proxies that talks to the MBeanServer due to the fact the Microkernel is JMX based. The overhead at runtime is minimal since the Microkernel implementation is highly optimized, however when it is used with Java 5 a noticeable bottleneck appears due to the fact that the implementation of the JMX API classes javax.management.* provided by the Java Platform performs synchronization. This does not happen under JDK 1.4 since those classes are implemented by JBoss MX.

JBoss Portal services use a special kind of Model MBean called JBossServiceModelMBean which allows to unwrap the injected dynamic proxies and replace them by the real POJO services. This allows to remove the bottleneck with Java 5 and provide an extra boost of performances on JDK 1.4. By default that feature is enabled but it is possible to disabled it using command line arguments.

>run.sh -Dportal.kernel.no_proxies=false

Chapter 4. Upgrading 2.4 - 2.6

Warning

Before performing any instructions or operations mentioned below remember to backup your database content and the whole application server directory!

4.1. Manual upgrade

Although database schema remains the same in JBoss Portal 2.6 there are several differences that prevent from simple deployment of newest portal version using JBoss Portal 2.4 database. In this chapter we will list major ones and give instructions on how to manually update proper data.

Upgrading procedure can be quite straightforward:

  • Remove $JBOSS_HOME/server/default/deploy/jboss-portal.sar file.
  • Update data in portal database like described in following sections of this chapter
  • Deploy JBoss Portal 2.6

4.1.1. Theme

Themes in 2.6 version changed as now they contain additional areas - the best example is upper right corner where links like "Login", "Admin", "My Dashboard" are visable. If you use default theme like "renaissance" that is present in 2.6, you shouldn't need to do anything. To update your custom themes please refer to those bundled with portal as an example.

Note

If you stay with old theme files you may find JBP 2.6 unusable to the point that you may not even be able to log in

4.1.2. Database

Note

All things described in this section can be done using AdminPortlet. Treat this directions more as guideline if you need to automate migration for big portal deployment.

Database schema wasn't changed between 2.4 and 2.6 releases, but still content that is kept in it changed slightly in few areas. You can easily update the data manually by using tools proper for your RDBMS. If you use MySQL you can use MySQL Query Browser that can be downloaded from MySQL website.

Note

Instructions below refer to standard JBoss Portal 2.4 deployment. If you named core portlets, portlet instances or portlet windows differently you will need to make proper modifications in those steps.

4.1.2.1. Portlet names

Names of few core bundled portlets changed. To update them you need to:

In JBP_INSTANCES table:

  • Change "local.portal.CMSPorlet" in PORTLET_REF column to "local./portal-cms.CMSPortlet"
  • Change "local.portal.CMSAdminPorlet" in PORTLET_REF column to "local./portal-cms.CMSAdminPortlet"
  • Change "local.portal.ManagementPorlet" in PORTLET_REF column to "local./portal-admin.AdminPortlet"

Note

Instead of editing database you can destroy those instances in AdminPortlet and recreate them.

NavigationPortlet from JBP 2.4 is not present anymore. Its functionality is now realized by PageCustomizerInterceptor so all references to NavigationPortlet should be removed from all portal pages. You can do it either by cleaning up database content or by using AdminPortlet in Portal interface. In database you should remove:

  • Rows containing "local.portal.NavigationPortlet" in "PORTLET_REF" column in "JBP_INSTANCES" table.
  • Rows containing "NavigationPortletInstance" in "INSTANCE_REF" column in "JBP_WINDOW" table.
  • Rows containing "NavigationPortletWindow" in "NAME" column in "JBP_OBJECT" table.

Note

Instead of editing database you can just remove NavigationPortletInstance using AdminPortlet.

4.1.2.2. CMS

This is probably the less trival part to do directly in database. In JBP 2.6 version the way that CMS content is being displayed changed significantly. Please refer to Content Integration and CMS Portlet chapters for more information. Basically currently there is no need to have more than one instance of CMSPortlet and the portlet window displays CMS content not by referring to that portlet instance but by having proper content-type defined. In "default-object.xml you will find following configuration:

                  
<window>
   <window-name>CMSWindow</window-name>
   <content>
      <content-type>cms</content-type>
      <content-uri>/default/index.html</content-uri>
   </content>
   <region>center</region>
   <height>0</height>
</window>
                  
               

Open JBP_OBJECT_NODE table in your database schema. By looking at PATH column you will easily find any occurances of CMS in your portal deployment

For any row you will identify as referring to CMSPortletWindow in your system remember the number in PK column. It will be needed in next steps

Go to JBP_WINDOW table and find row with the same PK value like the one from JBP_OBJECT_NODE table. In such row replace "CMSPortletInstance" with a path to your CMS resource. For example by default portal is displaying "/default/index.html".

Go to JBP_PORTAL_OBJECT_PROPS table and add a row containing:

  • The number you remembered in "OBJECT_KEY" column.
  • "portal.windowContentType" in "NAME" column.
  • "cms" in "jbp_VALUE" column.

Note

Remember that you can also change portlet window content type and configure path to CMS resource using AdminPortlet

Chapter 5. Portlet Primer

Roy Russo

5.1. JSR-168 Overview

The JSR-168 specification aims at defining porlets that can be used by any JSR-168 portlet container also called portals. There are different portals out there with commercial and non-commercial licences. In this chapter we will briefly describe such portlets but for more details you should read the specifications available on the web.

Note

This section is a brief overview of the JSR-168 Portlet Specification , and it does not cover the topics in great detail. We strongly encourage portlet developers to read the Specification that can be found here .

As of today, JBoss portal is fully JSR-168 compliant, that means that any JSR-168 portlet will behave as it should inside the portal.

5.1.1. Portal Pages

A portal can be seen as pages with different areas and inside areas, different windows and each window having one portlet.

5.1.2. Rendering Modes

A porlet can have different view modes, three modes are defined by the specification but a portal can extend those modes. The 3 modes are:

  • VIEW - Generates markup reflecting the current state of the portlet.
  • EDIT - Should allow a user to customize the behaviour of the portlet.
  • HELP - Should provide some information to the user as to how to use the portlet.

5.1.3. Window States

Window states are an indicator of how much page real-estate a portlet should consume on any given page. There are 3 states defined by the specification:

  • NORMAL - A portlet shares this page with other portlets.
  • MINIMIZED - A portlet may show very little information or none at all.
  • MAXIMIZED - A portlet may be the only portlet displayed on this page.

5.1.4. Section Status

This overview of the portlet specification, is a work in progress. Check back for more in-depth analsis of the specification, but please read on for real-world cases of how to leverage the specification.

5.2. Tutorials

The tutorials contained in this chapter are targetted toward portlet developers. Although they are a good starting and reference point, we do heavily recommend that portlet developers read and understand the Portlet Specification (JSR-168). We also recommend using our JBoss Portal User Forums for user-to-user help, when needed.

5.2.1. Deploying your first portlet

5.2.1.1. Introduction

This section will introduce the reader to deploying his first portlet in JBoss Portal. It requires you download the HelloWorldPortlet from PortletSwap.com, using this link.

5.2.1.2. Package Structure

Portlets are packaged in WAR files, just like other JEE applications. A typical portlet WAR file can also include servlets, resource bundles, images, HTML, JSPs, and other static or dynamic files you would commonly include.

5.2.1.3. Portlet Class

Included in the download bundle you should have one java source file: HelloWorldPortlet\src\main\org\jboss\portlet\hello\HelloWorldPortlet.java, and it should contain the following:

package org.jboss.portlet.hello;

import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.UnavailableException;
import java.io.IOException;
import java.io.PrintWriter;

public class HelloWorldPortlet extends GenericPortlet
{
   protected void doView(RenderRequest rRequest, RenderResponse rResponse)
                     throws PortletException, IOException, UnavailableException
   {
      rResponse.setContentType("text/html");
      PrintWriter writer = rResponse.getWriter();
      writer.write("Hello World!");
      writer.close();
   }
}
               

Now let's dissect our simplest of portlets:

  • public class HelloWorldPortlet extends GenericPortlet

    All Portlets MUST implement the javax.portlet.Portlet interface. The Portlet API also provides a convenience implementation of this interface in the form of the javax.portlet.GenericPortlet class which, among other things, implements the Portlet render method to dispatch to abstract mode-specific methods to make it easier to support the standard portlet modes. It also provides a default implementation for processAction, init and destory methods. It is recommended to extend GenericPortlet for most cases.

  • protected void doView(RenderRequest rRequest, RenderResponse rResponse) throws
                               PortletException, IOException, UnavailableException

    As we extend from GenericPortlet and we are only interested in supported the VIEW mode, we only need to implement the doView method, and GenericPortlet's render implementation will call our implementation when the VIEW mode is requested.

  • rResponse.setContentType("text/html");

    Just like in the servlet-world, you must declare what content-type the portlet will be responding in. You need to do this before starting to write content or the portlet will throw an exception.

  • PrintWriter writer = rResponse.getWriter();
    writer.write("Hello World!");
    writer.close();

    Here we output the text Hello World! in our portlet window.

    Note

    Portlets are responsible for generating markup fragments, as they are included on a page and surrounded by other portlets. In particular, this means that a portlet outputting HTML MUST not output any markup that cannot be found in a body element.

5.2.1.4. Application Descriptors

JBoss Portal requires certain descriptors be included in your portlet WAR, for different reasons. Some of these descriptors are defined by the Portlet Specification, some are specific to JBoss Portal.

Now let's explain what each of these does:

  • portlet.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <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:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
                                     http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
                 version="1.0">
       <portlet>
          <portlet-name>HelloWorldPortlet</portlet-name>
          <portlet-class>org.jboss.portlet.hello.HelloWorldPortlet</portlet-class>
          <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>VIEW</portlet-mode>
          </supports>
          <portlet-info>
             <title>HelloWorld Portlet</title>
          </portlet-info>
       </portlet>
    </portlet-app>

    This file must adhere to its definition in the Portlet Specification. You may define more than one portlet application in this file.

    • <portlet-name>HelloWorldPortlet</portlet-name>

      Define your portlet name. It does not have to be the Class name.

    • <portlet-class>org.jboss.portlet.hello.HelloWorldPortlet</portlet-class>

      The Fully Qualified Name (FQN) of your portlet class must be declared here.

    • <supports>
         <mime-type>text/html</mime-type>
         <portlet-mode>VIEW</portlet-mode>
      </supports>

      The supports element allows you to declare all the markup types your portlet supports in the render method. This is accomplish via the mime-type element, which is required for every portlet. Of course, the declared MIME types must match the capability of the portlet. It also allows you to pair which modes and window states are supported for each markup type. In out case, as all portlets must support the VIEW portlet mode, we didn't have to declare it. We did need to declare that our portlet supports the text/html markup type. Hence, we are letting the portal know that it will be outputting text/html and only support a VIEW mode.

    • <portlet-info>
         <title>HelloWorld Portlet</title>
      </portlet-info>
      

      The portlet's title will be displayed as the header in the portlet window, when rendered, unless it is overridden programatically.

  • portlet-instances.xml

    <?xml version="1.0" standalone="yes"?>
    <!DOCTYPE deployments PUBLIC
       "-//JBoss Portal//DTD Portlet Instances 2.6//EN"
       "http://www.jboss.org/portal/dtd/portlet-instances_2_6.dtd">
    <deployments>
       <deployment>
          <instance>
             <instance-id>HelloWorldPortletInstance</instance-id>
             <portlet-ref>HelloWorldPortlet</portlet-ref>
          </instance>
       </deployment>
    </deployments>

    This is a JBoss Portal specific descriptor that allows you create an instance of a portlet. The portlet-ref value must match the portlet-name value given in the packaged portlet.xml. The instance-id value can be named anything, but it must match the instance-ref value given in the *-object.xml file we will explore below.

  • helloworld-object.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE deployments PUBLIC
       "-//JBoss Portal//DTD Portal Object 2.6//EN"
       "http://www.jboss.org/portal/dtd/portal-object_2_6.dtd">
    <deployments>
       <deployment>
          <parent-ref>default.default</parent-ref>
          <if-exists>overwrite</if-exists>
          <window>
             <window-name>HelloWorldPortletWindow</window-name>
             <instance-ref>HelloWorldPortletInstance</instance-ref>
             <region>center</region>
             <height>1</height>
          </window>
       </deployment>
    </deployments>

    *-object.xml files are JBoss Portal specific descriptors and allow users to define the structure of their portal instances as well as create/configure thier windows and pages. In our example, we create a portlet window, specify that it will display the markup generated by the HelloWorldPortletInstance portlet instance, assign it to the default.default page, and specify where it should appear on that page.

    • <parent-ref>default.default</parent-ref>

      Tells the portal where this portlet should appear. In this case, default.default specifies that this portlet should appear in the portal instance named default and the page named default.

    • <if-exists>overwrite</if-exists>

      Instructs the portal to overwrite or keep this object if it already exists. Possible values are overwrite or keep. overwrite will destroy the existing object and create a new one based on the content of the deployment. keep will maintain the existing object deployment or create a new one if it does not yet exist.

    • <window-name>HelloWorldPortletWindow</window-name>

      Can be named anything.

    • <instance-ref>HelloWorldPortletInstance</instance-ref>

      The value of instance-ref must match the value of instance-id found in the portlet-instances.xml.

    • <region>center</region>
      <height>1</height>

      Specify the layout region and order this window w