+ All Categories
Home > Documents > JSR – 168 Portlet Spec -...

JSR – 168 Portlet Spec -...

Date post: 13-Mar-2018
Category:
Upload: vuongbao
View: 218 times
Download: 2 times
Share this document with a friend
93
JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development Professional http://www.computer.org/certification http://www.goggins.com http://www.clutchsoftware.com
Transcript
Page 1: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

JSR – 168 Portlet Spec

Sean P. GogginsIEEE Certified Software Development Professional

http://www.computer.org/certification

http://www.goggins.com http://www.clutchsoftware.com

Page 2: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Agenda

1. Portal & Portlet Architecture & Strategy2. Pluto3. Our First Portlet4. The API Cliff’s Notes 5. EXO Portal… Plus, Deploy our Portlet in Portal

Two6. Jetspeed… Plus, Deploy our Portlet in Portal

Three!7. Liferay – My Favorite Portal

Page 3: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

A note on the “Moon Guy”

He means I have a Pre Baked Demo I can do…Stop me if I skip one you want to see

Page 4: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Elements of Portal (ificaton)

�Perhaps a definition of "Portals" from Javaworld.com might also be useful -– A portal is a Web-based application that provides

personalization, single sign-on, and content aggregation from different sources, and hosts the presentation layer of information systems. Aggregation is the process of integrating content from different sources within a Webpage. A portal may have sophisticated personalization features to provide customized content to users. Portal pages may have different sets of portlets creating content for different users.

Page 5: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

What is Portalification?

http://www.pythonline.com

Page 6: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

What is a Portlet?

�A portlet is a Java technology based web component, managed by a portlet container, that processes requests and generates dynamic content. Portlets are used by portals as pluggable user interface components that provide a presentation layer to Information Systems.

Page 7: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet and Portal TogetherStatic View

Page 8: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet and Portal TogetherDynamic View

Page 9: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Why Build a Portal?

�To solve some specific business need�Usually associated with content

aggregration

Page 10: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Steps in building a Portal

�Gather Requirements– Portal’s require a more comprehensive architecture

than standard web or J2EE apps

�Build an Information Architecture– Content– User Interface– Portlets– Search Engine– Taxonomy

Page 11: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Taxonomy Creation and Maintenance

Categorize ContentCategorize ContentAssetsAssets

Label andLabel andPersonalizePersonalize

IndexIndex

Inventory Inventory Content Content

Page 12: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

� Define the strategy

� Create an organization focused on taxonomy creation

� Define purpose and intended use (users) of taxonomy

� Prioritize needs:

– Concepts if you’re inventing

– Processes if you’re low skill service based

– Competencies if you’re high skill service based

� Decide basic metaphor for structuring information

� Choose a methodology/approach to building the taxonomy

� Classify information assets and categorize them

� Verification

� Implement Technology Support (JSR-168 compliant Portal?)

� Maintain

Steps in Building a Taxonomy

Page 13: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Building Portal Metadata – Dublin Core

RightsCoverageRelation

LanguageSourceIdentifier

FormatTypeDate

ContributorPublisherDescription

SubjectCreatorTitle

http://dublincore.org/documents/dces/http://dublincore.org/documents/dcmi-type-vocabulary/

Page 14: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Look and Feel

�Most portlets are customized using Skins– Jetspeed– EXOPortal– Liferay

�Search is an important part of any portal effort these days.

Page 15: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

JSR-168 / Java Portlets

�Javax.portlet package�Like other java applications

– Addition of portlet classes– Addition of portlet.xml deployment descriptor– WAR file deployment

�Different than other java applications– Portal handles the layout, aggregation,

personalization and single sign on

Page 16: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Why not use servlets & .jsp’s?

�Absence of personalization interface and support for persistence of personalization information in servlet architecture

�Servlet architecture doesn’t define aggregation on the desktop

Page 17: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet & Servlet both

�End in “let”�Are java components�Have container managed lifecycles

– Servlet container (tomcat)– Portlet container (pluto)

�Generate dynamic content�Manage sessions�Share a deployment and class loading paradigm

Page 18: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

But only PortletsPortletsPortlets

�Generate Fragments (not complete documents)

�Have container managed, predefined states– Window States– Portlet Modes

�Are not directly bound to a URL

Page 19: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

…and Only Servlets…

�Can set the URL client request�Can set HTTP headers in responses�Can establish response character encoding

Page 20: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portal Page

Page 21: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet Architecture

Page 22: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

WSRP

�OASIS Standard – Web Services for Remote Portals

�Portals that support WSRP can display Portlets from other WSRP enabled Portals

Page 23: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Integrating Existing Applications into the Portal

�Write a thin web service and develop a portlet for that application

�Write a WSRP layer on top of the application and have the application host itself as a portlet producer

�Application rewrite, factoring business logic and persistence out of the legacy app.

Page 24: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Part Two

Pluto

Page 25: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Installing Pluto

Page 26: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Installing Plutohttp://portals.apache.org/pluto/install.html

�CVS Client – I just used Eclipse� Install Maven� Install Tomcat�Edit build.properties file�Add %MAVEN_HOME%\bin directory to

path�Root Directory of PLUTO Project�Execute `maven fullDeployment`�Check it out!

Page 27: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Installing Plutohttp://portals.apache.org/pluto/install.html

�Build.properties settings– maven.tomcat.home=c:/tomcat5.0– maven.tomcat.version.major=5

Page 28: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

If your Maven Build Works

Page 29: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Interesting Eclipse Plugins –Where Portal Construction is Going

•For Eclipse Generation of Portlets•http://plutoeclipse.sourceforge.net/

•Maven Eclipse Plugin–http://maven.apache.org/reference/plugins/eclipse/properties.html

Page 30: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

JSR-168 Establishes

�Portlet Container – Pluto is the reference implementation

�Portlet API– Requests– Preferences– User Information– Deployment Packaging

�Relationship between portlet and portletcontainer

Page 31: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portal – Just Another Web App

�WEB-INF (Familiar to Servlet & JSP folks)– Web.xml– Portlet.xml

�Pluto Specific Deployment Directory– $TOMCAT_HOME/webapps/pluto/data

• Portletentityregistry.xml – portlet & portlet app definitions

• Pageregistry.xml – Describes how the portal page looks

Page 32: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Using Ant for War FilesInit

<property file="build.properties"/>

<property name="src.dir" value="src"/>

<property name="build.dir" value="build"/>

<property name="dist.dir" value="dist"/>

<property name="classes.dir" value="${build.dir}/classes"/>

<property name="lib.dir" value="lib"/>

<property name="web-inf.dir" value="WEB-INF"/>

<target name="init">

<mkdir dir="${build.dir}"/>

<mkdir dir="${classes.dir}"/>

<mkdir dir="${dist.dir}"/>

<mkdir dir="${lib.dir}"/>

</target>INIT

Page 33: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Using Ant for War FilesCompile

<target name="compile" depends="init">

<javac destdir="${classes.dir}" deprecation="true" debug="true" optimize="false">

<src>

<pathelement location="${src.dir}"/>

</src>

<classpath>

<fileset dir="${lib.dir}">

<include name="*.jar">

</include>

</fileset>

<fileset dir="${tomcat.shared.lib.dir}">

<include name="*.jar">

</include>

</fileset>

</classpath>

</javac>

</target>

COMPILE

Page 34: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Using Ant for War FilesWar

<target name="war" depends="compile">

<war destfile="${dist.dir}/${war.name}.war" webxml="WEB-INF/web.xml">

<classes dir="${classes.dir}"/>

<lib dir="${lib.dir}"/>

<webinf dir="${web-inf.dir}"/>

</war>

</target>

WAR

Page 35: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Pageregistry.xml

Portal Application Id.portletId

Page 36: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

portletentityregistry.xml

Portal Application Id

Portlet Id

Page 37: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet Errors

Page 38: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet Errors – Did you Deploy?

maven deploy -Ddeploy=FULL_PATH_TO_YOUR_PORTLET_WAR

Page 39: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Part Three

Build our First Portlet

Page 40: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet Modes

�Mandatory support for– View– Edit– Help

�JSR-168 supports custom, vendor defined portlet modes

Page 41: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Window State

�Three States defined in JSR-168– Normal– Maximized– Minimized

�Custom states supported

Page 42: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Build our First PortletDefine Project Structure

Define our ConstructionFile structures, etc.

Page 43: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Build our First PortletCode the Java

package com.clutchsoftware.portlets;

import java.io.IOException;

import java.io.Writer;

import javax.portlet.GenericPortlet;

import javax.portlet.PortletException;

import javax.portlet.RenderRequest;

import javax.portlet.RenderResponse;

public class CardinalsOne extends GenericPortlet

{

protected void doView(RenderRequest request, RenderResponse response)

throws PortletException, IOException

{

System.out.println("TEST OUTPUT");

response.setContentType("text/html");

Writer writer = response.getWriter();

writer.write("Help, I'm a portlet, and I'm trapped in a portal framework!");

}

}

Code the Java

Page 44: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Build our First PortletBuild the web.xml

Build the XML

Page 45: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Build our First PortletPortlet.xml

Build the XML

Page 46: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Build our First PortletAnt Build Script

Run the ant build script

Page 47: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Build our First Portlet

Perform the PLUTO Deployment

Page 48: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Build our First Portlet

Edit the portletentityregistry.xml file

Make sure this is the same as your class name in your java file

Page 49: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Build our First Portlet

Edit the pageregistry.xml file

Page 50: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Build our First Portlet

Page 51: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Part Four

An API Tour

Page 52: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

GenericPortlet

�Base class for java portlet specification�Implements Portlet and PortletConfig

interfaces of the portlet API�Key methods

– doDispatch()– doView()– doHelp()– doEdit()

Page 53: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet Interface

� init()� processAction(ActionRequest, ActionResponse)� render(RenderRequest, RenderResponse)� destroy()

«interface»PortletRequest

«interface»ActionRequest

«interface»RenderRequest

«interface»PortletResponse

«interface»ActionResponse

«interface»RenderResponse

Page 54: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

RenderResponse object –Content Types

� Portlets can produce content using the RenderResponse writer or it may delegate generation of content to a servlet or .jsp

� Set content type– public void setContentType(String type);

� Get Default Content Type for the Portal– public String getResponseConentType();

� List of all supported content types– public java.util.Enumeration getResponseContentTypes()

Page 55: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

RenderResponse object –Writing Content to a Portal Page

� Where portlets can write– Output stream– Writer

� Most use getWriter() method on the RenderResponse object– public java.io.PrintWriter getWriter() throws

java.io.Exception;

Page 56: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

PortletURL

�A portlet can create a URL that targets itself inside the portlet container – PortletURL’s

�Key methods on RenderResponse– createRenderURL()– createActionURL()

�Key PortletURL object methods– setParameter(String name, String value)– setParameters(java.util.Map parameters)– setSecure() [true to enable security, false to disable it]

Page 57: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

What does a Portlet Have to Implement?

�GenericPortlet’s– getTitle()– doView()– Constructor

Page 58: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Lifecycle of a Portlet

�Creation of the portlet– Loading the classes– Invocation of constructor– init()

�Processing Requests– render()– processAction()

�Death of a Portlet– destroy()

Page 59: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet RequestsRequest Attributes

�Request Attributes – Pass java objects

between portlets, servlets& JSP’s

– PortletRequest Attributes are identical to HTTPServletRequestattributes

«interface»PortletRequest

«interface»ActionRequest

«interface»RenderRequest

Page 60: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet RequestsRequest Properties

�Request Properties– Allows access to

container or server properties

– Vendor dependent– Not portable across

implementations

«interface»PortletRequest

«interface»ActionRequest

«interface»RenderRequest

Page 61: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet RequestsRequest Parameters

�Request Parameters– Name value pair– String object name– One or more String

object values

«interface»PortletRequest

«interface»ActionRequest

«interface»RenderRequest

Page 62: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet RequestsRequest Security

�Request Security– getAuthType()– getRemoteUser()– isUserInRole()– getUserPrincipal()

«interface»PortletRequest

«interface»ActionRequest

«interface»RenderRequest

Page 63: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet ResponsesPortletResponse Base Interface

�Three methods– setProperty(String key,

String value)– addProperty(String key,

String value)– encodeURL()

«interface»PortletResponse

«interface»ActionResponse

«interface»RenderResponse

Page 64: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet ResponsesRenderResponse Interface

�Numerous Methods– createActionURL()– createRenderURL()– setContentType()– setTitle()– getNamespace()– getLocale()– ….

«interface»PortletResponse

«interface»ActionResponse

«interface»RenderResponse

Page 65: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet ResponsesActionResponse Interface

�Numerous Methods– setWindowState() throws

WindowStateException– setPortletMode() throws

PortletModeException– sendRedirect()– setRenderParameter()– setRenderParameters()

– ….

«interface»PortletResponse

«interface»ActionResponse

«interface»RenderResponse

Page 66: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

PortletContext

�PortletConfig Interface provides access– getPortletContext()

�PortletContext– getServerInfo() – Returns a string that

provides the name and version number of the portlet container

– getMajorVersion() / getMinorVersion() –Return major and minor versions of the portletAPI

Page 67: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlet Sessions

�PortletSession Object– Obtained through a PortletRequest object– A façade over HTTPSession

�getPortletSession()

Page 68: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Part Five

EXO Portal

Page 69: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

EXO Portlet Deployment

Page 70: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Build.xml Modifications for EXO

Page 71: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Result – One WAR for Each Portal

Page 72: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Seeing the EXO Deployment

Page 73: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

EXO – Deployment Eclipse Plugin

�Demo

Page 74: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

General Thoughts on EXO-Portal

�Deployment documentation is unclear– Reasonably well organized– Not written by somebody who understands

• How to use a spell checker• The English language

�LocalHost deployment on Tomcat crashed and/or exhibited non-deterministic behavior frequently.

Page 75: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Part Six

Jetspeed

Page 76: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!Basic Requirements

� It is expected that the user is familiar with both the Apache Maven project tool and the Apache Ant build tool.

�Ant 1.5 or higher�Maven 1.0 or higher�Java 1.4 or higher�Servlet 2.3:

Tomcat 4.1.xorTomcat 5.x

Page 77: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!CVS Checkout Instructions

�Web Access�http://cvs.apache.org/viewcvs/jakarta-jetspeed-2/�Anonymous CVS Access

– This project's CVS repository can be checked out through anonymous (pserver) CVS with the following instruction set. When prompted for a password for anonymous, simply press the Enter key.

– cvs -d :pserver:[email protected]:/home/cvspublic login cvs -z3 -d :pserver:[email protected]:/home/cvspublic co jakarta-jetspeed-2

– Updates from within the module's directory do not need the -d parameter.

Page 78: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!Building Jetspeed -1

Page 79: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!Building Jetspeed -2

Building Jetspeed 2If you are using the default Hypersonic database, this procedure requires two terminal sessions. If you are using another database, skip the immediate section below on Terminal Session #1.

�������������� ��������������������� �������������������������� ��������������������������

Terminal session #2, build the portal and all components and unit test Jetspeed-2:

�������������� ������ !������"����������� �������������� ���������#�� !��

Page 80: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!Building Jetspeed -3

http://portals.apache.org/jetspeed-2/getting-started.html

Page 81: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!Building Jetspeed -4

Deploying Jetspeed into TomcatWe only cover deploying to Tomcat 4 and Tomcat 5. Step #1 below is optional if you are NOT using the default Hypersonic database.

1. If you are using the Hypersonic SQL database, make sure you have terminated the test HSQLserver. Then in the same terminal, start the production Hypersonic database by typing

maven start.production.server

2. (in seperate window/terminal session)

cd ${jetspeed-2-home}

3. maven quickStart

This will recreate the DB to deploy into. WARNING This will drop all the tables and data in the production database.

4. Start up Tomcat. With a browser, go to:

http://localhost:8080/jetspeed

Page 82: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!Building Jetspeed -5

Page 83: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!Portlet Deployment – 1

Page 84: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!Portlet Deployment – 2

Ya put your .war filed portlet in here…

Page 85: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!Portlet Deployment – 3

<fragment id="88" type="portlet" name="dodgers::DodgersDone">

<property layout="TwoColumns" name="row" value=“4" />

<property layout="TwoColumns" name="column" value="0" />

</fragment>

Notice the Syntax similarity with pluto –dodgers.DodgersDone

Page 86: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!Portlet Deployment – 4

Documentation Says – You don’t need to Restart tomcat for the changes to be recognized•Half True

•If you don’t, it does show the portlet frame•But, the portlet doesn’t work until you restart tomcat

Page 87: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Portlets on Jetspeed!Portlet Deployment – 5

Page 88: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Jetspeed – General Thoughts

�Jetspeed 1 is relatively stable, but not JSR-168 compliant

�Jetspeed 2 is unstable– Portlets work and minutes later… don’t work– Sometimes the container won’t start…. And

then it will�Like Pluto, there is no binary download

available yet.

Page 89: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Part Seven

Miscellaneous Notes & My Favorite Open Source Portal – Liferay

Page 90: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Open Source Portlets

http://sourceforge.net/projects/portlet-opensrc

Page 91: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Liferay

� I’ve been running a Liferay Portal 24/7 for two years using Jboss & Oracle

�Decent Eclipse setup instructions available�Quite the Resource Pig�Requires knowledge of J2EE beyond servlets &

.jsp’s to operate�Learning curve is steeper, but the flexibility and

stability far exceed other portals I’ve shown here tonight.

Page 92: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Sean P. Gogginshttp://www.clutchsoftware.com

Liferay Deployment

Page 93: JSR – 168 Portlet Spec - java.ociweb.comjava.ociweb.com/javasig/knowledgebase/2004-09/Sean_Goggins... · JSR – 168 Portlet Spec Sean P. Goggins IEEE Certified Software Development

Thank You

Sean P. [email protected]


Recommended