+ All Categories
Home > Documents > WA2089 WebSphere Portal 8.0 · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java...

WA2089 WebSphere Portal 8.0 · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java...

Date post: 11-Mar-2018
Category:
Upload: dinhquynh
View: 216 times
Download: 3 times
Share this document with a friend
52
WA2089 WebSphere Portal 8.0 Programming Web Age Solutions Inc. USA: 1-877-517-6540 Canada: 1-866-206-4644 Web: http://www.webagesolutions.com EVALUATION ONLY
Transcript
Page 1: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

WA2089 WebSphere Portal 8.0Programming

Web Age Solutions Inc.USA: 1-877-517-6540Canada: 1-866-206-4644Web: http://www.webagesolutions.com

EVALUATION O

NLY

Page 2: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

The following terms are trademarks of other companies:

Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.

Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both.

UNIX is a registered trademark of The Open Group in the United States and other countries.

Linux is a trademark of Linus Torvalds in the United States, other countries, or both.

IBM, WebSphere, DB2 and Tivoli are trademarks of the International Business Machines Corporation in the United States, other countries, or both.

Other company, product, and service names may be trademarks or service marks of others.

For customizations of this book or other sales inquiries, please contact us at:

USA: 1-877-517-6540, email: [email protected]: 1-866-206-4644 toll free, email: [email protected]

Copyright © 2013 Web Age Solutions Inc.

This publication is protected by the copyright laws of Canada, United States and any other country where this book is sold. Unauthorized use of this material, including but not limited to, reproduction of the whole or part of the content, re-sale or transmission through fax, photocopy or e-mail is prohibited. To obtain authorization for any such activities, please write to:

Web Age Solutions Inc.439 University AveSuite 820TorontoOntario, M5G 1Y8

EVALUATION O

NLY

Page 3: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Table of ContentsChapter 1 - Introduction to WebSphere Portal Server.......................................................13

1.1 What is a Portal.......................................................................................................131.2 An Example of a WebSphere Portal Site................................................................141.3 General Portal Architecture.....................................................................................151.4 WebSphere Portal Products.....................................................................................151.5 A Typical Network Architecture for WebSphere Portal.........................................171.6 WebSphere Portal Server .......................................................................................171.7 WebSphere Portal Server Architecture...................................................................181.8 WebSphere Portal Server Architecture...................................................................191.9 WebSphere Portal Server Architecture...................................................................201.10 Page Aggregation Modules...................................................................................201.11 Portlet....................................................................................................................211.12 WebSphere Portal Built-in Portlets.......................................................................211.13 Portlet Application................................................................................................221.14 Portlet Mode and State..........................................................................................221.15 WebSphere Portal Information.............................................................................231.16 Java Portlet Specification 1.0 (JSR-168)..............................................................241.17 Java Portlet Specification 2.0 (JSR-286)..............................................................251.18 Portlet Security Overview.....................................................................................251.19 Portal Access Control............................................................................................261.20 Portal User Management.......................................................................................261.21 Credential Vault Service.......................................................................................271.22 Best Practices For Development...........................................................................271.23 Summary...............................................................................................................281.24 Review Questions..................................................................................................281.25 Review Answers....................................................................................................29

Chapter 2 - Portlet Development Using Rational Application Developer 8.5...................312.1 The RAD 8.5 Product..............................................................................................312.2 Portlet Development Support..................................................................................312.3 RAD 8.5 Installation...............................................................................................322.4 Portal Server 8.0 Installation...................................................................................322.5 Basic Steps in Portlet Development........................................................................332.6 Project Structure......................................................................................................342.7 Portlet Project..........................................................................................................352.8 Create a Project Structure........................................................................................362.9 portlet.xml Editor....................................................................................................372.10 Create a Test Portal Server....................................................................................372.11 Create a Test Portal Server....................................................................................382.12 Managing the Server.............................................................................................392.13 Unit Testing...........................................................................................................392.14 Unit Testing...........................................................................................................402.15 Export Portlet Application....................................................................................412.16 Summary...............................................................................................................412.17 Review Questions..................................................................................................41

EVALUATION O

NLY

Page 4: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

2.18 Review Answers....................................................................................................42Chapter 3 - Introduction to JSR 286 Based Portal Programming .....................................43

3.1 What is JSR 286?....................................................................................................433.2 Relationship With Java SE and Java EE.................................................................443.3 Comparing Portlets with Servlets............................................................................443.4 Comparing Portlets with Servlets............................................................................453.5 A Portal Site............................................................................................................463.6 Portlet......................................................................................................................463.7 Portlet Application..................................................................................................473.8 The portlet.xml File.................................................................................................483.9 Portlet Definition in portlet.xml..............................................................................483.10 Portlet Container...................................................................................................493.11 Portlet Window.....................................................................................................503.12 Review Questions..................................................................................................513.13 Review Answers....................................................................................................513.14 Summary...............................................................................................................51

Chapter 4 - Basic Portlet Programming.............................................................................534.1 Model-View-Controller in Portlet Application.......................................................534.2 The Portlet Interface................................................................................................544.3 The Hello World Portlet..........................................................................................554.4 Portlet Lifecycle - Initialization..............................................................................554.5 Portlet Lifecycle – Request Handling.....................................................................564.6 Two Phase Request Processing...............................................................................574.7 Two Phase Request Processing Architecture..........................................................584.8 The render Method..................................................................................................584.9 The PortletRequest Interface...................................................................................594.10 The PortletResponse Interface..............................................................................594.11 The RenderResponse Interface.............................................................................604.12 PortletURL............................................................................................................614.13 PortletURL Example.............................................................................................624.14 The processAction Method...................................................................................624.15 The ActionRequest Interface.................................................................................634.16 Example: Handling Form Submission..................................................................634.17 Example: Handling Form Submission..................................................................644.18 The ActionResponse Interface..............................................................................644.19 Example Use of Render Parameters......................................................................654.20 Dealing With Browser History..............................................................................664.21 The GenericPortlet Class.......................................................................................674.22 The GenericPortlet Class.......................................................................................674.23 User Session Management....................................................................................684.24 Using the Session..................................................................................................684.25 Relationship of PortletSession with HttpSession..................................................704.26 Session Usage Example........................................................................................704.27 End of Portlet Life.................................................................................................714.28 Portlet Configuration.............................................................................................714.29 Initialization Parameters........................................................................................72

EVALUATION O

NLY

Page 5: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

4.30 Portlet Context......................................................................................................724.31 Invoking the View Layer......................................................................................734.32 Controller Logic Implementation Techniques......................................................744.33 Review Questions..................................................................................................754.34 Review Answers....................................................................................................764.35 Summary...............................................................................................................76

Chapter 5 - Portlet Preferences..........................................................................................775.1 Portlet Preferences..................................................................................................775.2 Portlet Preferences API...........................................................................................785.3 Example: Reading Preferences...............................................................................795.4 Updating Portlet Preferences...................................................................................795.5 Example: Updating Preference...............................................................................815.6 Validating Preference Update.................................................................................825.7 Example Validator Class.........................................................................................825.8 Review Questions....................................................................................................835.9 Review Answers......................................................................................................845.10 Summary...............................................................................................................84

Chapter 6 - Display Generation.........................................................................................856.1 Techniques in View Development..........................................................................856.2 PortletRequestDispatcher include/forward Details.................................................856.3 JSR 286 Tags...........................................................................................................876.4 The defineObjects Tag............................................................................................876.5 The defineObjects Tag............................................................................................886.6 Example defineObjects Usage................................................................................886.7 The actionURL Tag.................................................................................................896.8 The renderURL Tag................................................................................................906.9 The param Tag........................................................................................................906.10 The namespace Tag...............................................................................................906.11 National Language Support...................................................................................916.12 Resource Bundle File............................................................................................916.13 Displaying Translated Text...................................................................................926.14 Portlet Resource Bundle........................................................................................936.15 Providing Locale Specific Preference Defaults....................................................946.16 Review Questions..................................................................................................946.17 Review Answers....................................................................................................946.18 Summary...............................................................................................................95

Chapter 7 - Advanced Programming Topics.....................................................................977.1 JSR 286 Annotations...............................................................................................977.2 @RenderMode........................................................................................................977.3 @ProcessAction Annotation...................................................................................987.4 Setting the Action Name in URL............................................................................997.5 Portlet Caching........................................................................................................997.6 Basic Caching Setup.............................................................................................1007.7 Programmatic Cache Control................................................................................1007.8 Validation Based Caching.....................................................................................1017.9 Validation Caching API........................................................................................101

EVALUATION O

NLY

Page 6: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

7.10 Example Validation Control...............................................................................1027.11 Summary.............................................................................................................103

Chapter 8 - Portlet Services.............................................................................................1058.1 Portlet Services......................................................................................................1058.2 Writing a Portlet Service.......................................................................................1058.3 Defining the Portlet Service Interface...................................................................1068.4 Example - AccountService....................................................................................1068.5 Writing the Portlet Service Implementation.........................................................1078.6 java.util.prefs.Preferences.....................................................................................1078.7 Example – AccountServiceImpl...........................................................................1088.8 Registering Portlet Services..................................................................................1098.9 WAS Admin Console PortletServiceRegistryService..........................................1098.10 Using a Service from a Portlet............................................................................1108.11 Example – Using a Service.................................................................................1108.12 Content Access Service.......................................................................................1118.13 Content Access Service.......................................................................................1128.14 Summary.............................................................................................................1128.15 Review Questions................................................................................................1128.16 Review Answers..................................................................................................112

Chapter 9 - Portlet Communication Overview................................................................1159.1 Portlet Communication Techniques......................................................................1159.2 Comparison of Portlet Communication Techniques.............................................1169.3 Comparison of Portlet Communication Techniques.............................................1179.4 Comparison of Portlet Communication Techniques.............................................1189.5 Which Portlet Communication Technique Should I Use?....................................1189.6 Which Portlet Communication Technique Should I Use?....................................1199.7 Summary...............................................................................................................120

Chapter 10 - Portlet Event................................................................................................12110.1 Portlet Events......................................................................................................12110.2 Event Architecture..............................................................................................12210.3 Example Use Case...............................................................................................12310.4 Event Flow Sequence..........................................................................................12310.5 Sequence Diagram..............................................................................................12410.6 Defining an Event in portlet.xml.........................................................................12510.7 Using Default Namespace...................................................................................12510.8 Creating the Payload Class..................................................................................12610.9 Publishing an Event.............................................................................................12610.10 Consuming an Event.........................................................................................12710.11 Consuming an Event.........................................................................................12810.12 The @ProcessEvent Annotation.......................................................................12810.13 Details about @ProcessAction..........................................................................12910.14 Additional Notes About Events........................................................................12910.15 Portlet Event Configuration..............................................................................13010.16 Summary...........................................................................................................130

Chapter 11 - Public Render Parameter.............................................................................13111.1 Public Render Parameters...................................................................................131

EVALUATION O

NLY

Page 7: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

11.2 Example Use Case...............................................................................................13211.3 Steps to Using Public Render Parameters...........................................................13211.4 Define Public Render Parameter in portlet.xml..................................................13311.5 Declare Public Render Parameter for a Portlet...................................................13311.6 Setting Value of a Public Render Parameter.......................................................13411.7 Example Setting Public Render Parameter.........................................................13511.8 Getting Value of a Public Render Parameter......................................................13511.9 Additional API....................................................................................................13611.10 Limitations........................................................................................................13611.11 Summary...........................................................................................................136

Chapter 12 - Client-side Click-to-Action Portlet Communication..................................13712.1 Client-side Click-to-Action ("Live Text")..........................................................13712.2 Example Use Case...............................................................................................13712.3 Example Use Case...............................................................................................13812.4 Specify a Live Text Source.................................................................................13912.5 Specify a Live Text Source – Example...............................................................13912.6 Specify a Live Text Target..................................................................................14012.7 Specify a Live Text Target - Example................................................................14112.8 Looking Underneath the Hood............................................................................14212.9 Looking Underneath the Hood............................................................................14312.10 Summary...........................................................................................................143

Chapter 13 - Developing JSF Portlets for WebSphere Portal..........................................14513.1 What is JavaServer Faces (JSF)?........................................................................14513.2 Why Use JSF?.....................................................................................................14513.3 Nature of a JSF Application................................................................................14613.4 JSF and MVC......................................................................................................14713.5 JSF and MVC......................................................................................................14813.6 Faces Servlet.......................................................................................................14813.7 Managed Bean.....................................................................................................14913.8 The View.............................................................................................................15013.9 A Simple JSF Application...................................................................................15113.10 The Input Form: form.jsp..................................................................................15213.11 The Result: thanks.jsp.......................................................................................15313.12 The Controller: AddressBean............................................................................15313.13 Page Flow or Navigation Rule..........................................................................15413.14 How Does the Application Work?....................................................................15413.15 How Does the Application Work?....................................................................15513.16 Creating a JSF Portlet........................................................................................15613.17 Creating a JSF Portlet........................................................................................15713.18 Creating a JSF Portlet........................................................................................15713.19 Navigation State Management..........................................................................15813.20 Advanced: Obtaining Core JSF Objects...........................................................15813.21 JSF 2.0 and Portlets 2.0.....................................................................................15813.22 Summary...........................................................................................................159

Chapter 14 - Web Services for Remote Portlets..............................................................16114.1 Remote Portlets...................................................................................................161

EVALUATION O

NLY

Page 8: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

14.2 WSRP..................................................................................................................16114.3 WSRP Terminology............................................................................................16214.4 WSRP Benefits....................................................................................................16314.5 WSRP Architecture.............................................................................................16314.6 Information Artifacts...........................................................................................16414.7 Security Issues.....................................................................................................16414.8 JSR-286 and WSRP 2.0......................................................................................16414.9 Pre-defined Container Events.............................................................................16514.10 Pre-defined Container Events...........................................................................16614.11 Summary...........................................................................................................166

Chapter 15 - Using AJAX in a Portlet.............................................................................16715.1 What is AJAX?...................................................................................................16715.2 A Simple Example..............................................................................................16815.3 The Old Way.......................................................................................................16915.4 The AJAX Way...................................................................................................17015.5 Two Key Aspects of AJAX.................................................................................17015.6 Advantages of the AJAX Approach....................................................................17115.7 The Basic AJAX API..........................................................................................17115.8 Creating the XMLHttpRequest Object................................................................17215.9 The XMLHttpRequest Object Basics..................................................................17215.10 Complete Example............................................................................................17315.11 The Timeline.....................................................................................................17515.12 Using AJAX from a Portlet...............................................................................17515.13 JSR-286 and AJAX...........................................................................................17615.14 The ResourceServingPortlet Interface .............................................................17615.15 Output From serveResource()...........................................................................17615.16 ResourceURL....................................................................................................17715.17 AJAX Request Timeline...................................................................................17815.18 Steps to be Taken by a Portlet...........................................................................17815.19 A Complete Example........................................................................................17915.20 The View JSP....................................................................................................17915.21 The Portlet Class...............................................................................................18015.22 Summary...........................................................................................................180

Chapter 16 - The Dojo Toolkit.........................................................................................18116.1 Introduction.........................................................................................................18116.2 Installation...........................................................................................................18216.3 Dojo Capabilities.................................................................................................18316.4 Simple Example – Tab Widget...........................................................................18316.5 Simple Example – Tab Widget...........................................................................18416.6 How Does DOJO Work?.....................................................................................18416.7 Importing Packages.............................................................................................18516.8 Widget Basics......................................................................................................18616.9 Widget Basics......................................................................................................18616.10 Widget Layout Example...................................................................................18716.11 The Two byId() Methods..................................................................................18816.12 Widget Properties..............................................................................................188

EVALUATION O

NLY

Page 9: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

16.13 Widget Events...................................................................................................18916.14 Common Features of Widgets...........................................................................19016.15 Form Input Widgets..........................................................................................19016.16 The Button Widget............................................................................................19116.17 The Checkbox Widget.......................................................................................19116.18 The ComboBox Widget....................................................................................19216.19 The ComboBox Widget....................................................................................19316.20 The ComboBox Widget....................................................................................19316.21 The ComboBox Widget....................................................................................19416.22 The FilteringSelect Widget...............................................................................19516.23 The FilteringSelect Widget...............................................................................19616.24 The FilteringSelect Widget...............................................................................19616.25 The FilteringSelect Widget...............................................................................19716.26 The DateTextBox Widget.................................................................................19916.27 Layout Widgets.................................................................................................19916.28 Other Common GUI Widgets...........................................................................20016.29 Creating Widget Instances Programmatically...................................................20016.30 Creating Widgets Programmatically.................................................................20116.31 Summary...........................................................................................................20216.32 Review Questions..............................................................................................20216.33 Review Answers................................................................................................20216.34 Review Answers................................................................................................203

Chapter 17 - Using Dojo in WebSphere Portal 8.0..........................................................20517.1 Dojo and WebSphere Portal 8.0..........................................................................20517.2 Dojo and AJAX Portlets......................................................................................20517.3 Dojo Versions in WebSphere Portal 8.0.............................................................20617.4 Dojo Best Practices.............................................................................................20617.5 Dojo Support in RAD 8.5 – New Project............................................................20817.6 Dojo Support in RAD 8.5 – New Project............................................................20917.7 Dojo Support in RAD 8.5 – Existing Project......................................................20917.8 Dojo Tools in RAD 8.5.......................................................................................20917.9 Generated Dojo Code in RAD 8.5......................................................................21017.10 Generated Dojo Code in RAD 8.5....................................................................21117.11 Summary...........................................................................................................211

Chapter 18 - Spring MVC Portlets...................................................................................21318.1 Portlets.................................................................................................................21318.2 Portlets.................................................................................................................21318.3 Portlets.................................................................................................................21418.4 Spring Portlet MVC Framework.........................................................................21518.5 Spring MVC and Portlet Configuration..............................................................21718.6 Spring Required JARS........................................................................................21718.7 Configuring Spring Portlet MVC Framework....................................................21818.8 Configuring Spring Portlet MVC Framework....................................................21818.9 Spring Portlet Views...........................................................................................21918.10 Spring Portlet Handler Mappings......................................................................22018.11 Mapping on Render Parameters........................................................................221

EVALUATION O

NLY

Page 10: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

18.12 Mapping on Render Parameters........................................................................22218.13 Handling Portlet Actions...................................................................................22218.14 Session Attributes..............................................................................................22318.15 Global Session...................................................................................................22418.16 JSR-286 Resource Serving................................................................................22518.17 JSR-286 Events.................................................................................................22518.18 Summary...........................................................................................................226

Chapter 19 - Developing WebSphere Portal Themes and Skins.....................................22719.1 Changes in WebSphere Portal 8.0 Themes.........................................................22719.2 Theme and Skin Concepts...................................................................................22819.3 Using WebDAV to Access Theme Files.............................................................22819.4 Creating a Custom Theme...................................................................................22919.5 Customizing the New Theme..............................................................................22919.6 Important Styles..................................................................................................23019.7 Dynamic Content Spot........................................................................................23019.8 Configuring Dynamic Content Spot....................................................................23119.9 Developing a Theme as an EAR File..................................................................23219.10 Developing a Theme as an EAR File................................................................23219.11 Registering Themes Deployed as an EAR........................................................23319.12 Registering Themes Deployed as an EAR........................................................23319.13 WebSphere Portal Tag Libraries.......................................................................23419.14 Using WebSphere Portal Tag Libraries............................................................23519.15 Managing Themes and Skins............................................................................23519.16 Module Theme Framework...............................................................................23619.17 Summary...........................................................................................................237

Chapter 20 - WebSphere Portal Personalization Framework..........................................23920.1 Overview of Personalization...............................................................................23920.2 Overview of Personalization...............................................................................24020.3 Presenting the Personalized Content...................................................................24020.4 Presenting the Personalized Content...................................................................24120.5 Creating a Personalization Rule..........................................................................24220.6 Personalization Campaigns.................................................................................24220.7 Personalization Campaigns.................................................................................24320.8 Content Spots......................................................................................................24320.9 Content Spots......................................................................................................24320.10 Personalization JAR Files.................................................................................24420.11 Personalization Resources.................................................................................24420.12 Personalization Resources.................................................................................24520.13 Personalization Portlets.....................................................................................24620.14 Personalization Rules........................................................................................24620.15 Personalization Rules........................................................................................24720.16 Personalization Rules Process Flow..................................................................24720.17 Summary...........................................................................................................248

Chapter 21 - Portlet Build and Deployment Process.......................................................24921.1 Introduction.........................................................................................................24921.2 Overview of the Build Process............................................................................250

EVALUATION O

NLY

Page 11: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

21.3 The Build Process...............................................................................................25021.4 Installing a Portlet Web Module.........................................................................25121.5 How is a Portlet Web Module Installed?............................................................25221.6 How is a Portlet Web Module Installed?............................................................25321.7 Deploying Portlets Within an EAR.....................................................................25321.8 Managing Portlet Web Modules.........................................................................25421.9 Managing Portlet Web Modules.........................................................................25521.10 Managing Portlet Applications.........................................................................25521.11 Managing Portlet Applications.........................................................................25621.12 Managing Portlets.............................................................................................25621.13 Managing Portlets.............................................................................................25721.14 Adding a Portlet to a Page.................................................................................25821.15 Configuring a Portlet.........................................................................................25821.16 Copying a Portlet Application...........................................................................25921.17 Copy a Portlet....................................................................................................25921.18 Removing a Portlet From a Page......................................................................25921.19 Uninstalling a Portlet Application.....................................................................26021.20 Summary...........................................................................................................261

Chapter 22 - iWidget Portlet............................................................................................26322.1 Introduction to iWidget.......................................................................................26322.2 iWidget Portlets...................................................................................................26322.3 Anatomy of an iWidget.......................................................................................26422.4 Creating an iWidget............................................................................................26522.5 The iWidget Editor..............................................................................................26622.6 Developing the Business Logic...........................................................................26622.7 Lifecycle Callback Methods...............................................................................26722.8 Firing an Event....................................................................................................26722.9 Consuming an Event...........................................................................................26822.10 Wiring...............................................................................................................26822.11 Summary...........................................................................................................269

Chapter 23 - Portal Development Best Practices.............................................................27123.1 Architecture Best Practices.................................................................................27123.2 Controller (Portlet) Guidelines............................................................................27223.3 Controller (Portlet) Guidelines............................................................................27323.4 Controller (Portlet) Guidelines............................................................................27323.5 View (JSP) Guidelines........................................................................................27423.6 View (JSP) Guidelines........................................................................................27523.7 View (JSP) Guidelines........................................................................................27623.8 Configuration Management................................................................................27723.9 Session Management...........................................................................................27723.10 Security Guidelines...........................................................................................27823.11 Java Performance Tips......................................................................................27823.12 Portlet Performance Tips...................................................................................27923.13 Performance Testing Guidelines.......................................................................27923.14 Summary...........................................................................................................280

EVALUATION O

NLY

Page 12: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

EVALUATION O

NLY

Page 13: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

ObjectivesKey topics of this chapter

What is a Portal?

General Portal Architecture

WebSphere Portal Products

WebSphere Portal Architecture

Basic Portlet Concepts

Java Portlet Specification Overview

Portal Security Overview

Best Practices for Portlet Development

1.1 What is a Portal

An IBM Definition

◊ A Portal provides a secure and single point of interaction with diverse information, business processes, and people, personalized to a user's needs and responsibilities

Capabilities of a Portal site that distinguish it from a regular web site:

◊ A single point of access to several applications

◊ Multiple applications can share the same web page space.

◊ Users logon only once and access many applications.

◊ Applications can save user logon credentials for a backend resource (such as SAP or DB2) and perform implicit logon.

What is a Portal

A Portal is a tool for managing (including organizing, categorizing, personalizing, streamline accessing and sharing) diverse information resources from both business processes and people.

You may first hear the term “Portal" when you visited Web gateways, such as Yahoo, and see many definitions of Portal, such as knowledge Portals, Commerce Portals, Publishing Portals, Tax Portals, BI Portals, Self Service Portals, and so on.

EVALUATION O

NLY

Page 14: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

1.2 An Example of a WebSphere Portal Site

Portlets

An Example of a WebSphere Portal Site

Here is an example of a Portal site built on WebSphere Portal. It shows:

● Custom applications deliver timely and relevant information.

● Various portlet applications performing different business tasks (e.g. currency converter, real-time stock watcher, stock chart).

● Each portlet is an independent application; however, aggregated, a lot of business information can be seen at once by the user.

All this is accessed via a browser.

14

EVALUATION O

NLY

Page 15: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

1.3 General Portal Architecture

ConsumerPortal

B2BPortal

EmployeePortal

CustomerPortal

Administration, Page generation, Collaboration, Publish & Subscribe, Search & Navigation, Personalization, Integration,...

Vertical

Horizontal

General Portal Architecture

Horizontal Portals are the primary infrastructure upon which a Vertical Portal is built. They provide services, such as portal administration, portal page generation, collaboration, content publishing and subscription to Vertical Portals.

Vertical Portals are built upon the horizontal layer and represent a specific Portal instance, usually defined by a major topic or domain. It includes the corresponding data, people, and applications. Vertical Portals could be industry specific or functional area specific. Examples of Vertical Portal might include: customer self service, company operations, sales force support, knowledge management, collaborative, online banking, e-commerce and store fronts. The Vertical Portal is largely defined by the data, people, and processes it serves.

1.4 WebSphere Portal Products

WebSphere Portal Server

◊ Offers core portal services (e.g. aggregation, personalization)

WebSphere Portal Enable

◊ Includes WebSphere Portal, plus:

IBM Workplace Web Content Management

WebSphere Portal Document Manager

WebSphere Portal Extend

◊ Includes WebSphere Portal Enable, plus:

15

EVALUATION O

NLY

Page 16: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

IBM Lotus Forms

Integrated Lotus tools such as QuickPlace and Sametime

IBM Accelerators for WebSphere Portal

◊ Pre-packaged portlets, software, frameworks, and templates designed to address specific business requirements and speed up the deployment of portal sites

WebSphere Portal Products

There are various IBM accelerator products, each of which addresses different project needs, including:

● IBM Mobile Portal Accelerator

● IBM Business Process Accelerator

● IBM Content Accelerator

● IBM Enterprise Suite Accelerator

● IBM Self-Service Accelerator

● IBM Collaboration Accelerator

● IBM Dashboard Accelerator

● IBM Learning Accelerator

16

EVALUATION O

NLY

Page 17: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

1.5 A Typical Network Architecture for WebSphere Portal

WebServer

WebSphere PortalServer

LDAPServer

Router

Public NetworkDMZ Internal Network

AuthenticationServer

Internet

DBServer

1.6 WebSphere Portal Server

Runs on WebSphere Application Server 8.0 as a set of regular Java EE Enterprise Applications.

Provides the Portal Framework

◊ Is the horizontal piece that addresses the common portal needs of organizations

◊ Allows the end user to interact with enterprise applications, people, content, and processes

◊ Allows the plug in of new features or extensions called portlets in the same way that a servlet is an application within a Web container

Comes with a set of built-in Portlets ready to use

Comes with WebSphere Portlet Factory 8.0

◊ An Eclipse-based tool for visually creating, viewing, and running portlets that access web services and backend systems, including Lotus Domino, SAP, PeopleSoft, and DB2

17

EVALUATION O

NLY

Page 18: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

WebSphere Portal Server

WebSphere Portal Server provides an open, flexible, and scalable infrastructure for creating and deploying many categories of portals that are accessible from a wide variety of desktop and mobile devices. It is an integrated solution that includes:

● WebSphere Portal Server Framework - allows you to establish personal home pages for every employee, business partner, and customer as well as serve wireless pervasive devices. The framework architecture is the connection point for attaching applications and services for customers.

● Portlets - WebSphere Portal server comes with a variety of portlets ready to use. Plus, you can build portlets yourself to add to the portal catalog of functions for customers.

● WebSphere Application Server - this market share leading Web application server is actually a family of products that makes it easy to build Java server pages, write applications, manage performance, and data mine portal click streams. It also provides dozens of other vital Web services.

● Tivoli Directory Server - provides the industry standard user authentication mechanism.

1.7 WebSphere Portal Server Architecture

Portlet EngineUser Interface

Portal Service

LDAPPortal

Configuration Database

WebSphere Portal Server

PortletContainer

Security

WebSphere Application Server

AuthenticationProxy

TrustAssociationInterceptor

18

EVALUATION O

NLY

Page 19: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

WebSphere Portal Server Architecture

WebSphere Portal Server 8.0 runs on WebSphere Application Server 8.0. It consists of the following components:

● Portlet Container: Responsible for loading the portlet code, rendering the portlet display and notifying portlets of various events.

● User interface: allows users to construct their Portal pages for look and feel.

● Portal Service: provides services including resources, user and security management, for the Portal server

● Portal Configuration Database: Portal server saves various configuration and application state information in the database.

In the front of WebSphere Portal is an authentication proxy server, such as Tivoli WebSeal. The Trust Association Interceptor enables WebSphere Portal to receive authenticated requests from the proxy.

1.8 WebSphere Portal Server Architecture

Portlet Container

◊ Core component of WebSphere Portal Server

◊ Main responsibility is to provide a runtime environment to instantiate, use and destroy portlets

Other Portal Components

◊ Portal servlet: examines each HTTP request and send event messages to appropriate Portlets.

◊ Page aggregation modules: accumulates information from each Portlet and renders them in a single page for the user device

◊ Portlet access: controls the access to Portlets during page aggregation, page customization and other access points.

19

EVALUATION O

NLY

Page 20: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

1.9 WebSphere Portal Server Architecture

PortalServlet

PageAggregation

Portlet Container/

Portlets

Services

Portal Registry

Access Control

WebSphere Portal Server

Portal Configuration Database

User BeanLDAP

WebSphere Portal Server Architecture

The Portal Servlet examines the URL and header fields of each incoming request and invokes the appropriate handler. The request is handled in two phases. In the first phase, Portlets have an opportunity to send event messages to other Portlets. In the second phase, the appropriate page aggregation module for the user’s device renders multiple Portlets in a single page. The access control component checks the access rights of Portlets during page aggregation.

1.10 Page Aggregation Modules

Each page aggregation module renders the contents in different markup languages for different devices:

◊ HTML Aggregation component:produce HTML page for desktop HTML Web browser

◊ WML Aggregation component: produce WML page for Wireless Access Protocol (WAP) devices, e.g. mobile phones

◊ iMode Aggregation component: produce cHTML markup for mobile

20

EVALUATION O

NLY

Page 21: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

devices, for example, NTTDoCoMo network

Other modules may be added for Voice XML and PDA devices

Each aggregation module has a set of Portlets that can actually produce the markup appropriate for the device

1.11 Portlet

Is a piece of Java code (like a Servlet) that runs on a portal server to provide content that forms a fragment of a portal page.

◊ Analogous to an application window in a desktop environment.

A portlet typically implements an entire application (such as tracking past order status).

Multiple instances of the same portlet can be placed on a page.

◊ The page may contain instances of other portlets.

◊ Each portlet can be seen as a separate application running in a common web based desktop like environment.

◊ A portlet can be minimized or maximized.

◊ Portlets can communicate with each other through messages.

In some cases, multiple separate portlets work together to implement a complete application. For example, a portlet may display a list of news items. When an item is clicked, another portlet displays the details.

Portlet

A Portal is best explained in terms of a GUI desktop operating system. In the desktop you have multiple application windows open. Each application can be seen as a Portlet. Sometimes, you may have multiple copies of the same application running. We can do the same with Portlets. Each copy can display different data. For example, a SQL portlet can display customer list from an Oracle database. Another instance of the same portlet can display the orders from the DB2 database.

1.12 WebSphere Portal Built-in Portlets

WebSphere Portal Server provides a rich set of standard Portlets:

21

EVALUATION O

NLY

Page 22: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

◊ RSS Portlet: format Rich Site Summary data, commonly used for news feeds

◊ HTML web clipping portlets

◊ Weather portlet, Stock market portlets

◊ Notes Portlets: to access Lotus Notes e-mail, calendar, address book and to-do list (Portal Extend only)

◊ Exchange Portlets: to access Microsoft Exchange e-mail, calendar, address book and to-do list (Portal Extend only)

◊ Sametime Portlet: to access the SameTime instance message server (Portal Extend only)

◊ QuickPlace Portlet: access to a QuickPlace team room (Portal Extend only)

◊ Syndicated Content Portlets: provide news from news providers

View third party developed portlets at:

◊ http://catalog.lotus.com/wps/portal/portal/

1.13 Portlet Application

A portlet application is a group of portlets.

A portlet application is packaged within a web archive file (WAR).

An administrator installs a portlet application, thereby installing all the portlets within it.

1.14 Portlet Mode and State

A portlet can display different information based on its mode. The following modes are supported:

◊ View – The regular mode. Display application specific data or forms.

◊ Edit – Usually displays a form that allows the user to change the behavior of the portlet.

◊ Help – Shows online help.

22

EVALUATION O

NLY

Page 23: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

◊ Configure – Displays a form that allows the administrator to globally change the behavior of a portlet. This is an IBM custom mode.

A user can change the mode by clicking on the drop-down on the border of a portlet.

A portlet can be in one of these states:

◊ Maximized

◊ Minimized

◊ Normal

Portlet Mode and State

A weather forecast portlet will display the forecast in the view mode. A user can switch the mode to the edit mode and choose a different city. When the mode switches back to the view mode, the portlet shows the forecast for that city.

An administrator can use the configure mode and enter the host name of the weather forecast web service. Only an administrator can go to the configure mode.

The Portlet API allows for the definition of custom portlet modes.

1.15 WebSphere Portal Information

WebSphere Portal Server product page

◊ www.ibm.com/websphere/portal

Redbooks

◊ www.redbooks.ibm.com

Other sources (see URLs below):

◊ Portal 8.0 Documentation

◊ RAD 8.5 InfoCenter

◊ Portal Developer Zone

◊ JavaDoc for Portal API

23

EVALUATION O

NLY

Page 24: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

WebSphere Portal Information

Portal 8.0 Documentation:

http://www-10.lotus.com/ldd/portalwiki.nsf/

RAD 8.5 InfoCenter:

http://publib.boulder.ibm.com/infocenter/radhelp/v8/index.jsp

Portal Developer Zone:

http://www.ibm.com/developerworks/websphere/zones/portal/

JavaDoc for Portlet API:

http://jcp.org/aboutJava/communityprocess/final/jsr286/index.html

(Note: Need to download JSR-286 specification which contains javadocs)

1.16 Java Portlet Specification 1.0 (JSR-168)

The Java Portlet Specification 1.0 (JSR-168) introduces the basic portlet programming model with:

◊ Two phases of action processing and rendering in order to support the model-view-controller pattern

◊ Portlet modes, enabling the portal to advise the portlet what task it should perform and what content it should generate

◊ Window states, indicating the amount of portal page space that will be assigned to the content generated by the portlet

◊ Portlet data model, allowing the portlet to store view information in render parameters, session-related information in the portlet session, and per user persistent data in the portlet preferences

◊ A packaging format in order to group different Portlets and other Java EE artifacts needed by these Portlets into one portlet application which can be deployed to the portal server

24

EVALUATION O

NLY

Page 25: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

1.17 Java Portlet Specification 2.0 (JSR-286)

The Java Portlet Specification 2.0 (JSR-286) extends JSR-168 and brings to Java Portlets all the key capabilities introduced by WSRP 2.0. Examples include:

◊ Events — Enable portlets to communicate with each other through sending and receiving events.#

◊ Shared render parameters — Enable portlets to specify which render parameters they can share with other portlets.#

◊ Resource serving — Enables portlets to serve resources within the portlet context.

Java Portlet Specification 2.0 (JSR-286)

WSRP stands for Web Services for Remote Portlets and is a standard from OASIS which allows you to include portlets located on a remote portal server in a portal application running on a local portal server.

1.18 Portlet Security Overview

WebSphere Portal security leverages the security infrastructure provided by WebSphere Application Server:

◊ Java SE and Java EE security

◊ JAAS

◊ Transport layer security (SSL/TLS)

◊ Web Services security

WebSphere Portal provides additional services to enable portal specific security extensions

◊ Portal access control

◊ Portal user management

◊ Credential vault service

25

EVALUATION O

NLY

Page 26: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

Portlet Security Overview

Credential Vault Service: com.ibm.portal.portlet.service.credentialvault.spi

1.19 Portal Access Control

Portal Access Control (PAC) authorization model to enable instance-level protection of portal resources, based on role types and role inheritance. The artifacts defined by the PAC model are:

◊ Protected resource

◊ Protected resource hierarchy

◊ Virtual resource

◊ Role type

◊ Role

◊ Role block

◊ Ownership

Portal Access Control

PAC is a generic model, based on a set of simple rules and corresponding configuration artifacts that can be freely combined to create any sort of setup--from easy to complex access control.

1.20 Portal User Management

Portal user management is configurable through profiles managed by an API called PUMA

The Portal User Management Architecture (PUMA) System Programming Interface (SPI) provides interfaces for accessing the profiles of a portal User or Group.

It is used to find, create, modify and delete users and groups. Also, profile information about the currently logged in user can be retrieved.

26

EVALUATION O

NLY

Page 27: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

1.21 Credential Vault Service

The credential vault is a repository where credentials are stored.

Examples of credentials include:

◊ certificates

◊ private keys

◊ user Ids and passwords

WebSphere Portal provides a class called CredentialVaultService which portlets can use to store and retrieve credentials from the vault.

1.22 Best Practices For Development

Always use the industry standard specifications

◊ Protects cross-platform compatibility

◊ Accommodates industry standard security APIs

Use PUMA for accessing Portal User information

Use the Credential Vault to store sensitive data

Be careful of what data is passed to the client

Enable single sign-on as appropriate

Add timers to your code to help with performance tracking

Best Practices For Development

Security Considerations

1. Use the Credential Vault to store sensitive data. The Credential Vault is designed to securely store “secrets”, or pieces of data necessary for accessing applications, such as user Ids and passwords. Entries in the vault are called slots, and slots can be shared or non-shared. Shared means that the secret can be used by any user using that portlet. Non-shared means that every user must have his or her own secret stored in the slot.

There are two types of credentials: passive and active. Passive credentials give the portlet programmer access to the actual user ID and password. Active credentials give the portlet programmer access only to services enabled by the credential, such as a secure connection through an authentication proxy; the programmer does not actually see the secret itself.

27

EVALUATION O

NLY

Page 28: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

Using the Credential Vault enables single sign-on to avoid multiple login challenges and improves the user’s experience with the portal.

2. Be careful of what data is passed to the client. HTTP connections may not be secured, and certain browsers, especially on mobile devices, may not secure transmitted data effectively. So, if you use HTTP headers like cookies to pass application data back to the client, be sure that it is either encrypted appropriately, or is benign in nature and does not require securing.

3. Enable single sign-on as appropriate. Many customers gain access to the portal through a trust association interceptor (TAI) which translates user identity as established by some secure network intermediary into a portal identity. Your portlet needs to be able to either pass third-party user identity information to back-end applications that are enabled for the same authority, or translate the portal user identity into an external application user identity, such as through the use of the Credential Vault.

1.23 Summary

What is a Portal?

General Portal Architecture

WebSphere Portal Products

WebSphere Portal Architecture

Basic Portlet Concepts

Java Portlet Specification Overview

Portal Security Overview

Best Practices for Portlet Development

1.24 Review Questions

1. How is a portal site different from a typical web site?

2. What is a portlet?

3. What piece of middleware does WebSphere Portal Server run on top of?

4. What does a portlet container do?

5. What do JSR-168 and JSR-286 define?

28

EVALUATION O

NLY

Page 29: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 1 - Introduction to WebSphere Portal Server

1.25 Review Answers

1. Unlike a regular web site, a portal site provides a single point of access to several applications that share the same web page space, provides users with single sign-on access to many applications, and provides the ability to save user logon credentials and implicitly log on to a backend resource (such as SAP or DB2).

2. A portlet is a piece of Java code (like a Servlet) that runs on a portal server and provides content that forms a fragment of a portal page. It is analogous to an application window in a desktop environment and normally implements an entire application.

3. WebSphere Application Server, Network Deployment edition

4. A portlet container provides a runtime environment to instantiate, use, and destroy portlets.

5. The Java Portlet Specification 1.0 and 2.0, respectively

29

EVALUATION O

NLY

Page 30: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

EVALUATION O

NLY

Page 31: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

ObjectivesKey objectives of this chapter

Portlet development tools in RAD

Portlet projects

Testing portlets

2.1 The RAD 8.5 Product

RAD 8.5 is the development IDE to build Java and Java EE applications for the WebSphere Application Server 8.5 platform

◊ RAD 8.5 also provides tools to develop portlet applications for WebSphere Portal 8.0

Built on top of the open, highly pluggable Eclipse 3.6 platform with a set of plug-ins conforming to the Eclipse Workbench open standard APIs

The RAD 8.5 Product

Since WebSphere Portal is based on WebSphere Application Server, it is released well after the corresponding version of WebSphere Application Server. This means that the RAD version is always a version "ahead" of the WebSphere Portal version.

Even though RAD provides tools for the latest version of Java EE applications that are supported by WebSphere Application Server, these applications are not always supported on the version of WebSphere Portal supported by the same version of RAD. WebSphere Portal 8.0 does support the Java EE 6 applications you can develop with RAD 8.5 but this is not always the case.

2.2 Portlet Development Support

RAD 8.5 supports WebSphere Portal 8.0 development.

◊ The Portlet and Portal tools additional feature must be selected during installation or installed later

Various Portlet specific wizards and utilities create a highly productive development environment.

EVALUATION O

NLY

Page 32: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

Portlets can be tested using a Portal Server 8.0 run time. This runtime must be installed separately.

Portlet Development Support

RAD provides both portlet and portal development support. In this chapter, we will address portlet development.

Portlet development support focuses on wizards and utilities for creating "portlet projects" and the underlying portlets. A portlet project consists of one or more portlets and corresponds with a portlet application, which gets deployed to the portlet container running inside of WebSphere Portal Server.

On the other hand, portal development support focuses on wizards and utilities for creating "portal projects". A portal project consists of layouts, themes, and skins, all of which affect the look and feel of your portal site. Portal projects are not normally created from scratch; instead, the portal site from a WebSphere Portal Server is typically imported into a new portal project. The contents of the portal project are then modified. Afterwards, the portal project is deployed to WebSphere Portal Server.

2.3 RAD 8.5 Installation

The Portlet and Portal Tools feature must be selected during RAD 8.5 installation. This feature is available from the regular RAD 8.5 packaging.

2.4 Portal Server 8.0 Installation

WebSphere Portal is installed separately from RAD

32

EVALUATION O

NLY

Page 33: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

◊ You use the same software used to install WebSphere Portal in production but with different installation options and post-install commands to optimize for development

When installing you select the 'Base' installation type

◊ This will avoid installing extra features that are not often needed in development and testing portlets

You can also run the following command to improve performance<Portal Profile>/ConfigEngine/ConfigEngine enable-develop-mode-startup-performancePortal Server 8.0 Installation

Rather than a Full WebSphere Portal installation, select the "Base" installation option. The difference is that many portlets and sample pages showing some of the “out of the box” features are not installed when you choose the Base option. This helps optimize the test environment. The Base option includes only the administration portlets and welcome pages.

If you choose the Base installation (as recommended) and later require additional "out of the box" features, such as personalization or composite applications, you can individually add them to the installation. Refer to the following link for more instructions on how to do so:

UPDATE

http://publib.boulder.ibm.com/infocenter/wpdoc/v6r1m0/topic/com.ibm.wp.ent.doc/config/admin_add_main.html

The ConfigEngine command above is all one parameter with dashes between the words even though it wraps between lines above.

2.5 Basic Steps in Portlet Development

Create an Enterprise Application Project

33

EVALUATION O

NLY

Page 34: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

Create a new Portlet Project in the Enterprise Application

Create one or more Portlets

Create a Portal Server for unit testing and debugging

Deploy the Enterprise Application in the test server

Test or debug the application

Export the Portlet project as a WAR file for Portlet distribution

2.6 Project Structure

An Enterprise Application project represents a Java EE enterprise application.

◊ Contains other Java EE projects such as Web and EJB projects.

A Portlet project is a slightly customized version of a web project. This represents a portlet application.

◊ Contains the Portlet deployment descriptor - WEB-INF/portlet.xml.

How are things different from regular Java EE development?

◊ We don’t create plain Servlets in a Portlet project.

◊ We do not export the Enterprise application project as an EAR. Instead we export the Portlet project as a WAR file and distribute our Portlets.

Project Structure

A Portlet application is not a Java EE module. But it is virtually identical to a web module. The main difference is the existence of the WEB-INF/portlet.xml file.

Also, a web module is usually only a part of an application. The entire application is represented by the Enterprise Application module (EAR). A Portlet project, on the other hand, forms the entire Portlet application. We export such a project as a WAR file and distribute our Portlet application.

34

EVALUATION O

NLY

Page 35: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

2.7 Portlet Project

The src folder is the root of all Java class source code.

◊ The compiled .class files go to WEB-INF/classes.

The WebContent folder is the root of the J2EE web module structure

◊ Can directly contain JSP and HTML files.

◊ Usually, JSP and HTML files are stored in a markup specific folder (such as html, wml and chtml).

Portlet deployment descriptor (portlet.xml) is in the WEB-INF folder.

The web module deployment descriptor (web.xml) is in the WEB-INF folder.

35

EVALUATION O

NLY

Page 36: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

2.8 Create a Project Structure

Select File → New → Portlet Project

Enter these key values:

◊ Project name – name of the portlet project

◊ Target Runtime – choose WebSphere Portal v8.0

◊ EAR Project Name – Pick an existing enterprise application project or enter the name for a new project

◊ Configuration – Choose JSR 286 Portlet

◊ Create a portlet – Uncheck the box

Click Finish

Create a Project Structure

In order to change the Portlet API configuration you must click the 'Modify' button next to 'Configuration'.

If you create an Enterprise Application project first before the Portlet project it is important that the EAR project also targets WebSphere Portal 8.0 or the correct project settings may not get set.

36

EVALUATION O

NLY

Page 37: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

2.9 portlet.xml Editor

portlet.xml Editor

You can always click the Source tab to work directly with the file source.

2.10 Create a Test Portal Server

Right click on the Servers view and select New → Server. Choose WebSphere Portal v8.0 Server and click Next.

37

EVALUATION O

NLY

Page 38: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

2.11 Create a Test Portal Server

Enter the WebSphere administrator user ID and password.

Click Next

Enter the Portal administrator user ID and password (usually wpsadmin).

Click Finish.

38

EVALUATION O

NLY

Page 39: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

2.12 Managing the Server

2.13 Unit Testing

Deploy the project to the test server:

◊ In the Servers view, right click on the Portal 8.0 test server and select Add and Remove Projects.

◊ Add the enterprise application project.

◊ Right click on the Portlet project and select Properties → Server property and select the Portal server as the default server.

Right click on the Portlet project and select Run As → Run on Server.◊ RAD will start the server, if it's not started, publish the project to the

server, and open a browser. The Portal user from the Portal configuration is automatically logged in and the portlet is displayed in a test page.

39

EVALUATION O

NLY

Page 40: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

During development, RAD does not automatically re-publish (re-deploy) any changed code to the server, in order to optimize the performance of the portal test environment.

◊ Instead, you must right click on the server and select Publish to manually publish changes to the server.

Unit Testing

When you run a portlet project on the server, you're also given the option to publish changes to the server.

As a best practice, it's recommended to keep automatic publishing turned off. However, if you decide you want to enable automatic publishing, open the server configuration editor, expand the Publishing settings in the Overview tab, and click the Automatically publish when resources change radio button. Optionally, set the Publishing interval to a value different than the default value of 15 sec.

2.14 Unit Testing

When you test your project RAD automatically:

◊ Creates a label (a special type of page) called Rational Components◊ Creates a page underneath it matching the project name

(LabPortletProject below)

◊ Then adds the portlet to the page

This behavior is based on the Portlet Publishing settings in the Portal page of the server configuration editor.

40

EVALUATION O

NLY

Page 41: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

2.15 Export Portlet Application

Portlet projects are exported as Java EE WAR files.

In the Enterprise Explorer view, right click on the Portlet project and select Export → WAR file.

Enter the export destination (directory and file name).

Click Finish.

Deliver the exported WAR file to the administrator who can install the application using the WebSphere Portal Server administration screen.

2.16 Summary

RAD 8.5 is used to develop for WebSphere Portal 8.0

RAD 8.5 requires extra installed tools for portlet development support

The test Portal server can be configured and controlled from within RAD

2.17 Review Questions

1. When installing RAD, what must you also install in order to work with WebSphere Portal Server v8.0?

41

EVALUATION O

NLY

Page 42: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 2 - Portlet Development Using Rational Application Developer 8.5

2. What is the difference between the "Full" and the "Base" installation of WebSphere Portal Server?

3. What kind of project does a Portlet Project resemble?

4. How do you deploy portlets from within RAD to WebSphere Portal Server?

2.18 Review Answers

1. Portlet and Portal Tools

2. The Base installation option only installs the administration portlets and welcome pages. Many portlets and sample pages showing some of the “out of the box” features are not installed when you choose the Base option, which helps optimize the test environment.

3. Dynamic Web Project

4. To deploy portlets to WebSphere Portal Server from within RAD, you must first add the portlet project's associated enterprise application project to the server. Afterwards, you can right click on the portlet project and select Run As → Run On Server.

42

EVALUATION O

NLY

Page 43: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 3 - Introduction to JSR 286 Based Portal Programming

ObjectivesTopics discussed in this chapter are:

JSR 286 basics

Portlet

Portlet vs. Servlet

Portlet Deployment Descriptor

Portlet Applications

Portlet Container and Portal Server

Portlet Windows

3.1 What is JSR 286?

Java Specification Request (JSR) 286, known as the Portlet API 2.0, deals with a vendor neutral Java API for Portlet development

◊ http://www.jcp.org/en/jsr/detail?id=286

◊ Expert group includes IBM, Sun, BEA, Oracle and others.

◊ Spec version 2.0 was finalized in Jun 2008.

JSR 286 was preceded by JSR 168, which is also known as the Java Portlet Specification v1.0 (finalized in Oct 2003).

◊ JSR 286 is backward compatible with JSR 168.

The major new features provided by JSR 286 to the Portlet Specification include support for:

◊ Events

◊ Public render parameters

◊ Two-Phase Rendering

◊ Resource serving (leads to improved AJAX support)

◊ Portlet Filters

◊ WSRP 2.0

EVALUATION O

NLY

Page 44: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 3 - Introduction to JSR 286 Based Portal Programming

What is JSR 286?

A JSR is a process to develop new specifications under the Java Community Process (JCP). Program Management Office (PMO) is a group within Sun that manages JCP. Official definition of JSR is "The document submitted to the PMO by one or more Members to propose the development of a new Specification or significant revision to an existing Specification."

Latest constitution of JCP (v2.1) is found at http://www.jcp.org/en/procedures/jcp2_1.

3.2 Relationship With Java SE and Java EE

Portlet API 2.0 (JSR 286) requires Java SE 5, which provides new language features, including support for annotations, enumerations, and generics.

Portlet API 2.0 requires at minimum Java EE 1.4.

◊ Servlet 2.4

◊ JSP 2.0

The Portlet API builds on top of the Servlet and JSP API. This is done to reuse as much of the existing API set as possible.

Currently, the Portlet API is not a mandatory requirement for Java EE compliance.

A Portlet application is packaged as a WAR file. No new packaging structure is specified.

Relationship With Java SE and Java EE

The Portlet API 2.0 can also be compiled in Java SE 1.4. However, this version of the Portlet API does not support the following features:

• Annotations – RenderMode, ProcessAction, and ProcessEvent

• Enum – P3PUserInfos

• Generics for collections

3.3 Comparing Portlets with Servlets

Like Servlets, Portlets are a way to build web-based applications. Portlets and Servlets have many common features such as request, response and

44

EVALUATION O

NLY

Page 45: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 3 - Introduction to JSR 286 Based Portal Programming

session.

Portlet life cycle is managed by the Portlet Container.

Most vendors would extend their existing Web container to add support for Portlets.

A Servlet's reply renders the entire web page. A Portlet's reply only renders a small rectangular area of the web page (i.e., a markup fragment).

Servlet's service() method performs request event processing as well as display generation. A Portlet performs request processing only if the user submitted a form or hyperlink in that Portlet. During the display generation phase, all Portlets will need to render the display. As a result, request processing and display generation are performed by two separate methods.

3.4 Comparing Portlets with Servlets

A Portlet has a minimized or maximized state. A Servlet has no such state.

For a Servlet, the session is per user per web application. A Portlet can use a per user per Portlet session, or a per user per Portlet application session.

A Portlet can include output from a JSP or a Servlet.

◊ All request and session attributes are shared between them.

◊ As a result, part of the display rendering job can be performed by a Servlet. This comes in handy when you have complex Servlets in an existing web application that is being portalized.

45

EVALUATION O

NLY

Page 46: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 3 - Introduction to JSR 286 Based Portal Programming

3.5 A Portal Site

A Portal Site

A portal site hosts various Portlets. The Portlets share the same page. The page has a few common elements such as a header, footer and side bar. Each Portlet is responsible for generating the HTML markup of its own rectangular area.

3.6 Portlet

Responsible for rendering a portion of a portal page.

In many cases a portlet implements a complete application. Such as:

◊ Daily news

◊ Expense claim

◊ Phone book search

A portlet is implemented using a Java class and configuration entries in a deployment descriptor

This class needs to be the single point of entry for all features offered by the application.

46

Header Area

Sid

ebar

Footer Area

Portlet A Portlet B

Portlet C

Submit

Page

Portlet

EVALUATION O

NLY

Page 47: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 3 - Introduction to JSR 286 Based Portal Programming

More complex applications can be developed using multiple portlets.

◊ These related portlets can communicate with each other. For example, the phone book search portlet can be used to fill in the manager's name in the expense claim portlet.

Portlet

In a regular web based application, the features are implemented using several Servlets. In the portal world, an application is exposed to the user as a portlet. A portlet is implemented using a single Java class. That means all HTTP requests meant for the application are handled by this class.

3.7 Portlet Application

A portlet application is a collection of portlets.

A portlet application is packaged as a web module (WAR file).

Keep in mind, functionally, a single portlet may implement an entire application. Which means multiple applications can be bundled in a single web module.

◊ Sometimes, it may be easier to develop related portlets in a single application, such as Daily News, Stock Query and Weather portlets.

In addition to all the standard features of a WAR module, a portlet application also contains the portlet deployment descriptor WEB-INF/portlet.xml.

Portlet Application

Key aspects of a portlet application web module (WAR) file.

• JSP, HTML and image files in the root of the WAR file or in subdirectories.

• WEB-INF/classes contain compiled Java classes that implement included portlets and other utility classes.

• WEB-INF/lib contains JAR or ZIP file containing compiled Java classes that implement included portlets and other utility classes.

• WEB-INF/web.xml – The standard web module deployment descriptor.

• WEB-INF/portlet.xml – The portlet deployment descriptor.

47

EVALUATION O

NLY

Page 48: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 3 - Introduction to JSR 286 Based Portal Programming

3.8 The portlet.xml File

The web.xml file in Servlet 2.4 specification is not extensible. As a result a news schema to describe a portlet application was needed.

The portlet.xml file follows the schema: http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd.

All elements are declared in the "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" namespace.

The root element is <portlet-app> indicating the portlet application. Key attributes of this element:

◊ id – A unique name of the application. Optional.

◊ version – JSR 286 API version. Mandatory. Currently, the value is 2.0.

The portlet.xml File

Example portlet.xml file:<?xml version="1.0" encoding="UTF-8"?><portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" id="samplejsr286project.SampleJSR286ProjectPortlet.73cdd1f4d1">>

</portlet-app>

3.9 Portlet Definition in portlet.xml

Each portlet is defined using the <portlet> tag.

◊ A <portlet-app> can contain many <portlet> tags.

The <portlet> tag has only one attribute – id.

◊ It is optional and can be used to uniquely identify a portlet.

A <portlet> tag can have these child tags to fully describe the portlet.

◊ <portlet-name> - The name of the portlet. Must be unique within the

48

EVALUATION O

NLY

Page 49: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 3 - Introduction to JSR 286 Based Portal Programming

application.

◊ <display-name> - A language specific display name.

◊ <portlet-class> - The Java class that implements the portlet.

◊ <supports>/<portlet-mode> - Various modes that are supported by the portlet.

Portlet Definition in portlet.xml

Example:<?xml version="1.0" encoding="UTF-8"?><portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" id="com.ibm.samplejsr286project.SampleJSR286ProjectPortlet.b4a432f4d1"> <portlet> <portlet-name>Daily News Portlet</portlet-name> <display-name xml:lang="en">Daily News Portlet</display-name> <display-name>Daily News Portlet</display-name> <portlet-class>com.webage.portlets.DailyNewsPortlet</portlet-class> <init-param> <name>wps.markup</name> <value>html</value> </init-param> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> </supports> … </portlet> …</portlet-app>

3.10 Portlet Container

A service of the application server.

49

EVALUATION O

NLY

Page 50: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 3 - Introduction to JSR 286 Based Portal Programming

Portlet application modules (WAR) are deployed in a portlet container.

The container is responsible for:

◊ Loading portlet code and configuration from the WAR file.

◊ Managing lifecycle of portlets.

◊ Performing authentication.

◊ Notifying the portlets in a page of various events.

◊ Aggregating content rendered by all portlets in a page, plus the other common elements such as header, footer and sidebar to compose the final HTML document.

3.11 Portlet Window

The same portlet can be added multiple times to a page.

The container creates only one Java object instance for each portlet defined in portlet.xml file.

Each time a portlet is added to a page, a new portlet window is created.

A portlet window is assigned a unique id by the portal/portlet container

Each portlet window will have its own runtime state associated with it (window state, mode, portlet-scoped session state, and render parameters)

50

EVALUATION O

NLY

Page 51: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

Chapter 3 - Introduction to JSR 286 Based Portal Programming

3.12 Review Questions

1. A portlet application is packaged inside of a ______ file.

2. T/F: A portlet renders the entire web page.

3. T/F: In JSR 286, a portlet is defined inside the web.xml.

4. What is responsible for managing a portlet's lifecyle?

3.13 Review Answers

1. WAR

2. False. A portlet renders a rectangular region inside the web page.

3. False. A portlet is defined in WEB-INF/portlet.xml.

4. Portlet Container.

3.14 Summary

In this chapter, we learned about:

◊ The basics of JSR 286

◊ The module structure of WAR and EAR

◊ The portlet deployment descriptor file portlet.xml

◊ The difference between portlet instance and portlet window.

51

EVALUATION O

NLY

Page 52: WA2089 WebSphere Portal 8.0  · PDF fileProgramming Web Age Solutions Inc. USA: ... 1.16 Java Portlet Specification 1.0 ... 4.1 Model-View-Controller in Portlet Application

EVALUATION O

NLY


Recommended