corner imagecorner image FeaturesPluginsPlatformDocs & SupportCommunityPartners


Portlet Creation made easy !!!!!!!!!

    Contributed by Umachitra Damodaran
    March 2007


       Did you ever think of creating your own portlet ? Did you find a portal to deploy the portlet created? Did you try playing around with the Tools available? Did you find the right tool????
       If you haven't found one , please checkout the following
    To Begin With :

What is a Portal / Portlet Container / Portlet ?

A Portal is a “specialized” web application that provides value-added services such as

  • Personalization
  • Single Sign-On
  • Content aggregation from various sources
  • Secure search facilities
  • Localization of content

    A Portlet is Java technology based web component

  • Based on the JSR 168 specification.
  • Managed by a portal container
  • Generates a piece of markup called “fragment”
  • Fragment generated by a Portlet aggregates with that from other Portlets to form a portal page
  • Fragment generated by a Portlet may vary from one user to another depending on the user configuration

    A Portal Container

  • Provides runtime environment for Portlets
  • Manage life cycle of Portlets
  • Provide persistent storage for storing Portlet preferences
  • Cache the portlets
  • Receive requests from the portal to execute requests on the portlet

Netbeans 5.5 IDE

The NetBeans Portlet Plugin will make portlet development as easy as writing a normal Java application, with all the features of portlets made available.
It helps in faster development , deployment and testing of portlets.

Java Application Platform SDK Update 2

The Application Platform SDK includes the portletcontainer and also provides the users with a Portal driver to test and deploy portlets.

For installation instructions, please visit:

  1. The Java Application Platform SDK Update 2 Installation Instructions and the Portlet Container 1.0 Beta Installation Instructions
  2. The NetBeans Portlet Plugin Installation Instructions

Portlet Creation and Deployment

The following diagram depicts the process of creating and deploying the portlet with Netbeans IDE and App Platform SDK.


Create a JSR 168 Application

1.Select New Project ->Portlet Applications -> JSR 168 Portlet Application in the Netbeans IDE.

Portlet

2.Enter the name of the Portlet and other valid data required and click Finish.

The Portlet Application is created with all the files required by the JSR168 specification for portlet.

The Portlet class extending GenericPortlet along with the doView,doEdit and doHelp method is created.

To Add a second portlet to the application ,Right click the portlet application created and choose New->File/Folder ,Choose Portlets under categories and follow the self guided instructions.

Clean and Build

Select the Portlet Application ,right click and choose “Clean and Build” Project.A war file get created under the “dist “ directory in Portlet Application location.

Add PortletContainer Driver

Install the Application Platform SDK in your local machine.The Portletcontainer Driver gets installed along with the SDK.To access the driver in the browser type “http://hostname:port/portletdriver/dt”.

Now add the Driver to Netbeans by following the steps below.

  1. Choose Tools - > Server Manager Menu.Choose Add server button .
  2. Choose “OpenSource Portlet container” for Server and click Next
  3. Select the location where you have installed SDK for glashfish home.Enter the password and click Next and Finish.

The Runtime Tab now shows the Driver added under Servers as below.

Deploy Portlet

Follow the steps below to deploy the portlet on the driver.

  1. Select the Portlet Application under the Projects tab ,right click and choose properties.
  2. Select the category Run and choose the portletcontainer driver in the drop down box for “Server” and click Ok.

3.Now Select the Portlet Application and right click and choose Deploy Project.

After deploying the portlet ,the Runtime tab lists the portlet under the Driver .

Launch Portlet

To view the portlet deployed,select the portlet deployed under the Driver in Runtime tab,right click and choose “Show portlet”.This will open the portlet in the browser.

Alternatively you can select the Driver ,right click and choose “Admin tool” which will launch the driver in a new browser. You can access the “Portlet tab” and view all the portlets deployed in that driver.

Undeploy Portlet.

To undeploy a portlet ,choose the portlet under Driver in Runtime Tab ,right click and choose “Undeploy”

Portlet Examples

  • Simple Portlet – Welcomes a User based on the User preferences set in Edit page

  • Session Portlet – Simple Portlet is modified to store the preferences in session variable.

  • Preferences Portlet – The example shows how the contents of the portlet can be displayed based on user preferences.( Note : portlet.xml file should be modified to store the preferences as given in the example ).

  • IPC Portlet – This example shows how a portlet communicates with another.(Note: sun-portlet.xml file should be created in the same location as portlet.xml. Add the "portletappengine-1.0.jar" under Libraries in the IDE.)

References

JSR 168 Portlet Specification : http://jcp.org/aboutJava/communityprocess/final/jsr168/

Portlet Repository : https://portlet-repository.dev.java.net/

Project Features

About this Project

Contrib was started in November 2009, is owned by Jiří Kovalský, and has 240 members.
 
 
Close
loading
Please Confirm
Close