JUG Sardegna supports Devoxx 2013
Vuoi ricevere uno zainetto? Clicca qui

Java User Groups
Java.net Partner
Get Firefox!

Portlet Java1 En

article of MassimilianoDessi

translated by Nelly Cannas ( nellycannas[#at*]yahoo[*dot#]it )

Portlet I

The Jakarta-Jetspeed project permits the construction of enterprise portals by means of portlets.
Portlets are web components that can be used as plug-in and managed by a container (Jetspeed).
The pages are created assembling portlets, which are pieces of pages and their role is giving information from sources.
The use of this technology allows users to construct their own portal, simply choosing where
, how and in which page put the portlets with the different contents.
Portlets can be java applications of several kinds, for example based on “actions” ( of Turbine, Velocity or Struts), contents from other sites through RSS [1], xslt, or publications made with Cocoon [2].
Another application allowed by portlets is the connection with content management systems , thanks to the fact that portlets are components.
Jetspeed shows the content adapting the language to the userÂ’s browser ; which can be an http client or a wap phone.
In order to consent the portability between commercial portlet containers, the java community process has been asked to create a standard for portlets (jsr 168*) .
The comitee is composed by ASF, Oracle, IBM, Sun, SAP, Borland, Novell, and many others.

Framework and components used in Jetspeed
LetÂ’s start to see in a logical-functional way how pages are assembled.
The assembling of portlets in a page is made by Turbine.
Turbine is a Jakarta framework for the creation of web application according to the paradigm MVC[3].
Turbine gives services and functionalities, particularly by means of the actions , services in background and template.
For template Turbine uses Velocity[4] or the Jsp.
Velocity is a Jakarta template engine, with his template (.vm Velocity macro) it is possibile to have access to java objects in his context.
Velocity represents the view of Turbine.

Creation of the pages

The calls to Jetspeed are like this:
The url contains the name of the user who is asking the page and refers to a psml file , even followed by possible params .
The psml file (Portal structure markup language) is an xml file which contains the site structure with the portlet entries for the different pages (but it is also possible to have separated files, for each page, that refer to each other to compose a psml file).
In the psml file it is shown what layout controller must be used to dispose the components that form the page (es.tab-controller, card- controller) .
At this point Jetspeed has all the information to compose the page.
Turbine, starting from the file default.vm of Velocity, that contains the general layoutof pages, creates the portlets according to the scheme imposed by the controller written in the psml.

Fig 1. JetspeedÂ’s architecture

Velocity macro
Velocity macro files (vm) are VelocityÂ’s templates, they are html files with variables that are substituted by Velocity

An example of the vm file is this default.vm :


In this file Velocity is asked to compose the layout of the page with a top, a left and a bottom and a piece that is called $screen placeholder and that we will see later.
The result will be a page like fig 2

Fig. 2 Jetspeed Layout

LetÂ’s see what is $screen placeholder.
As we have said, the psml file contains the portlets that must be visualized for the corresponding pages , and they are inserted for that page in the part called $screen placeholder, according to the modalities given by the controller.
So we will have the page like in fig3 and 4, that is the structure of the pages constructed by Turbine using VelocityÂ’s templates.

Fig 3 Turbine Layout

Fig 4 Layout Screen

Other functionalities
After the explanation of the most common use, with http calls, letÂ’s see other functionalities of Jetspeed.
In the folder WEB-INF\templates we have two subdirectories, Jsp and Velocity, as Turbine can use both templates.
In the subdirectories we have the folder html and wml: in the first are contained the template for browser http, in the second that for wap device.

Fig 5 Jetspeed on http :http://www.anglonaweb.it

Fig 6 Jetspeed on wap

With these template is managed the supplying of the contents on several canals.
The localization is managed by a service from turbine that is used by Velocity (l10n).
Jetspeed exposes even some web-services.
Configurating properly Velocity templates, it is possibile to have even different layouts for the portal pages, the only limit is the fantasy of the graphic who will choose the layout of the site, that will be translated in the VelocityÂ’s template.

Structure and content of psml file (Portal structure markup language)
It contains the structure of the userÂ’s portal, the portlets that will composed the pages and the controllers for the pages and even the portletsÂ’ skins.

<?xml version="1.0" encoding="iso-8859-1"?> 
  <portlets xmlns="http://xml.apache.org/jetspeed/2000/psml"> 
			<title>Default Jetspeed Page</title>
		<control name="TabControl"/> 
		  <controller name="CardPortletController"> 
		  <parameter name="parameter" value="pane"/>
		<skin name="orange-grey"/>
		  <entry parent="HelloVelocity"/> <br>
		  <layout> <br>
			 <property name="row" value="0"/> <br>
			 <property name="column" value="1"/> <br>
		  </layout> <br>
		  <entry parent="HelloJSP"/> 
				<property name="row" value="1"/> 
				<property name="column" value="0"/> 
In this first artiche we have seen what Jetspeed and the portlets provide:
  • The possibility for the users to create their own portals, according to the language and the device used
  • The connection with Content Management System thanks to the fact that the portlets are components, an example of Jetspeed with a cms: http://www.anglonaweb.it/.
The complete list of the sites created with Jetspeed are available on:

For the developer, as Jetspeed is a portal framework that exposes information, applications and services, it is possibile to find in it the application of the lates innovations, of standards, trends and methodologies of java programming, and even the use of other projects that are not of common use from who isnÂ’t a mailing list open-source haunter, but are used in commercial projects.

In the next article we will see in a more technical and detailed way the portletsÂ’ hierarchies, how they really work , which and how many are the base kinds, and how to deploy in a container portlet.

Bibliography and references
Jetspeed : Enterprise Information Portal: http://jakarta.apache.org/jetspeed
Turbine : Web Application framework: http://jakarta.apache.org/turbine
Velocity: Java Template Engine: http://jakarta.apache.org/velocity
Cocoon: http://xml.apache.org/cocoon
jsr168: http://www.jcp.org/en/jsr/detail?id=168
  1. Rss (Rich Site Summary) McLaughlin, “Java e Xml“, ed. O’Reilly 2001
  2. Cocoon McLaughlin, “Java e Xml“, ed. O’Reilly 2001
  3. http://jakarta.apache.org/turbine/turbine-2.3/model2+1.html
  4. Velocity e WebMacro Hunter-Crawford, “Java Servlet Programming II ed.“, ed. O’Reilly 2001----
MassimilianoDessì (desmax74[*](\)@(/)[*]yahoo[*](/).(\)[*]it)
He has started working at the Sistemi Informativi S.p.A (IBM) (http://www.sistinf.it) as a Java programmer. Since 2001 he has been working at the Atlantis S.p.A. (http://www.gruppoatlantis.com/), where he uses agile methodologies as the eXtreme programming (Xp), he develops enterprise Web-based applications with J2EE technology, like portals and content management system for territorial promotion.
In his free time he co- operates to the open-source Jakarta –Jetspeed project, and he takes care of the Italian version of Jetspeed. He studies electronic engineering at the University of Cagliari.

VeryQuickWiki Version 2.7.8 | Admin
Copyright © 2003-20013 Java User Group Sardegna Onlus. - Java, the Java Coffee Cup Logo and the Duke Logo are trademarks or registered trademarks of Oracle corporation in the U.S. and other countries.