WA2089 WebSphere Portal 8.0 Programming EVALUATION ONLY

Similar documents
"Charting the Course... WebSphere Portal 8 Development using Rational Application Developer 8.5. Course Summary

Lotus Exam IBM Websphere Portal 6.1 Application Development Version: 5.0 [ Total Questions: 150 ]

Advanced Software Engineering

IBM Realtests LOT-911 Exam Questions & Answers

Portlet Standard JSR 168 / JSR 286

IBM Workplace Collaboration Services API Toolkit

Advanced Web Systems 4- PORTLET API specifications (JSR 286) A. Venturini

Application Integration with WebSphere Portal V7

AD105 Introduction to Application Development for the IBM Workplace Managed Client

Advanced Topics in WebSphere Portal Development Graham Harper Application Architect IBM Software Services for Collaboration

The 60-Minute Guide to Development Tools for IBM Lotus Domino, IBM WebSphere Portal, and IBM Workplace Applications

IBM Rational Application Developer for WebSphere Software, Version 7.0

BEAWebLogic. Portal. Overview

Portal Express 6 Overview

WebSphere Portal Application Development Best Practices using Rational Application Developer IBM Corporation

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

Building JavaServer Faces Applications

Portlets (JSR-168) Dave Landers. BEA Systems, Inc. Dave Landers Portlets (JSR-168)

Standards and the Portals Project

JSR-286: Portlet Specification 2.0

IBM Workplace Software Development Kit

JBoss SOAP Web Services User Guide. Version: M5

Getting started with WebSphere Portlet Factory V6.1

de la session Portal 6.1 Administration

Java EE 6: Develop Web Applications with JSF

Getting started with WebSphere Portlet Factory V6

J2EE Development. Course Detail: Audience. Duration. Course Abstract. Course Objectives. Course Topics. Class Format.

Portal solutions May A guide to IBM WebSphere Portal, Version 5.1.

Peter Moskovits Principal Product Manager Oracle Corporation. Sue Vickers Group Manager Oracle Corporation

JSR-286: Portlet Specification 2.0

Oracle Developer Day

Getting started with WebSphere Portlet Factory V7.0.0

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

Index. NOTE: Boldface numbers indicate illustrations or code listing; t indicates a table. 281

IBM Rational Developer for System z Version 7.5

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

Developing Applications with Java EE 6 on WebLogic Server 12c

Inside WebSphere Application Server

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

Vision of J2EE. Why J2EE? Need for. J2EE Suite. J2EE Based Distributed Application Architecture Overview. Umair Javed 1

Tools to Develop New Linux Applications

BEAWebLogic. Portal. Tutorials Getting Started with WebLogic Portal

Entrust Identification Server 7.0. Entrust Entitlements Server 7.0. Administration Guide. Document issue: 1.0. Date: June 2003

Oracle Developer Day

Provisioning WPF based WP Composite Applications to Expeditor

C examcollection.premium.58q

Extended Search Administration

This presentation is for informational purposes only and may not be incorporated into a contract or agreement.

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

Deployment Scenario: WebSphere Portal Mashup integration and page builder

SAS Web Infrastructure Kit 1.0. Overview

Oracle Fusion Middleware 11g: Build Applications with ADF I

Magnolia Community Edition vs. Enterprise Edition. Non-Functional Features. Magnolia EE. Magnolia CE. Topic. Good value for money.

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP

BEAWebLogic. Portal. Tutorials Getting Started with WebLogic Portal

IBM Workplace Client Technology API Toolkit

Distributed Multitiered Application

WebSphere Application Server, Version 5. What s New?

Introducing Lotus Domino 8, Designer 8 and Composite Applications

2010 Exceptional Web Experience

Developing Web Applications for Smartphones with IBM WebSphere Portlet Factory 7.0

Improving Productivity

EPiServer Portals. Abstract

WA2097 WebSphere Application Server 8.5 Administration on Linux EVALUATION ONLY

Oracle Application Development Framework Overview

SOA Software Policy Manager Agent v6.1 for WebSphere Application Server Installation Guide

LOT-921 IBM WebSphere Portal 7.0 Migration and Support

Get Started on SOA. People Entry Point Interaction and Collaboration Services. Case for an SOA Portal

Oracle Fusion Middleware 11g: Build Applications with ADF I

Rich, personalized portals for the enterprise. IBM WebSphere Portal Version 6.1 reviewer s guide

Adobe ColdFusion 11 Enterprise Edition

How to Create Collaborative Communities Within Your Portal

Connecting to System i System i Access for Web

Federated Identity Manager Business Gateway Version Configuration Guide GC

SECTION II: JAVA SERVLETS

SAS Web Infrastructure Kit 1.0. Overview, Second Edition

Building the Enterprise

Java- EE Web Application Development with Enterprise JavaBeans and Web Services

e-business on demand Competitive Technical Briefing Enterprise Portals

Packaging for Websphere Development Studio was changed with V6R1.

C exam IBM C IBM Digital Experience 8.5 Fundamentals

Lotus Learning Management System R1

web.xml Deployment Descriptor Elements

Enterprise Modernization for IBM System z:

The team that wrote this redbook

Pervasive Web Application Architecture. History Scalability Availability Development Application Architecture

HYPERION SYSTEM 9 BI+ GETTING STARTED GUIDE APPLICATION BUILDER J2EE RELEASE 9.2

From Development to Production with the IBM WebSphere Application Server Liberty Profile IBM Redbooks Solution Guide

SAP Enterprise. Portal

AppDev StudioTM 3.2 SAS. Migration Guide

IBM Rational Host Access Transformation Services, Version 7.1

PeopleSoft Internet Architecture

Developing Applications for IBM WebSphere Portal 7.0

BEAWebLogic. Portal. Customizing the Portal Administration Console

IBM WebSphere Application Server - Express, Version 5.1

Java EE Application Assembly & Deployment Packaging Applications, Java EE modules. Model View Controller (MVC)2 Architecture & Packaging EJB Module

JBoss Portal Quickstart User Guide. Release 2.6.6

JavaServer Faces Technology, AJAX, and Portlets: It s Easy if You Know How!

Integration Developer Version 7.0 Version 7.0. Installation Guide

What's Coming in IBM WebSphere Portlet Factory 7.0

Transcription:

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

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: getinfousa@webagesolutions.com Canada: 1-866-206-4644 toll free, email: getinfo@webagesolutions.com 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 Ave Suite 820 Toronto Ontario, M5G 1Y8

Table of Contents Chapter 1 - Introduction to WebSphere Portal Server...13 1.1 What is a Portal...13 1.2 An Example of a WebSphere Portal Site...14 1.3 General Portal Architecture...15 1.4 WebSphere Portal Products...15 1.5 A Typical Network Architecture for WebSphere Portal...17 1.6 WebSphere Portal Server...17 1.7 WebSphere Portal Server Architecture...18 1.8 WebSphere Portal Server Architecture...19 1.9 WebSphere Portal Server Architecture...20 1.10 Page Aggregation Modules...20 1.11 Portlet...21 1.12 WebSphere Portal Built-in Portlets...21 1.13 Portlet Application...22 1.14 Portlet Mode and State...22 1.15 WebSphere Portal Information...23 1.16 Java Portlet Specification 1.0 (JSR-168)...24 1.17 Java Portlet Specification 2.0 (JSR-286)...25 1.18 Portlet Security Overview...25 1.19 Portal Access Control...26 1.20 Portal User Management...26 1.21 Credential Vault Service...27 1.22 Best Practices For Development...27 1.23 Summary...28 1.24 Review Questions...28 1.25 Review Answers...29 Chapter 2 - Portlet Development Using Rational Application Developer 8.5...31 2.1 The RAD 8.5 Product...31 2.2 Portlet Development Support...31 2.3 RAD 8.5 Installation...32 2.4 Portal Server 8.0 Installation...32 2.5 Basic Steps in Portlet Development...33 2.6 Project Structure...34 2.7 Portlet Project...35 2.8 Create a Project Structure...36 2.9 portlet.xml Editor...37 2.10 Create a Test Portal Server...37 2.11 Create a Test Portal Server...38 2.12 Managing the Server...39 2.13 Unit Testing...39 2.14 Unit Testing...40 2.15 Export Portlet Application...41 2.16 Summary...41 2.17 Review Questions...41

2.18 Review Answers...42 Chapter 3 - Introduction to JSR 286 Based Portal Programming...43 3.1 What is JSR 286?...43 3.2 Relationship With Java SE and Java EE...44 3.3 Comparing Portlets with Servlets...44 3.4 Comparing Portlets with Servlets...45 3.5 A Portal Site...46 3.6 Portlet...46 3.7 Portlet Application...47 3.8 The portlet.xml File...48 3.9 Portlet Definition in portlet.xml...48 3.10 Portlet Container...49 3.11 Portlet Window...50 3.12 Review Questions...51 3.13 Review Answers...51 3.14 Summary...51 Chapter 4 - Basic Portlet Programming...53 4.1 Model-View-Controller in Portlet Application...53 4.2 The Portlet Interface...54 4.3 The Hello World Portlet...55 4.4 Portlet Lifecycle - Initialization...55 4.5 Portlet Lifecycle Request Handling...56 4.6 Two Phase Request Processing...57 4.7 Two Phase Request Processing Architecture...58 4.8 The render Method...58 4.9 The PortletRequest Interface...59 4.10 The PortletResponse Interface...59 4.11 The RenderResponse Interface...60 4.12 PortletURL...61 4.13 PortletURL Example...62 4.14 The processaction Method...62 4.15 The ActionRequest Interface...63 4.16 Example: Handling Form Submission...63 4.17 Example: Handling Form Submission...64 4.18 The ActionResponse Interface...64 4.19 Example Use of Render Parameters...65 4.20 Dealing With Browser History...66 4.21 The GenericPortlet Class...67 4.22 The GenericPortlet Class...67 4.23 User Session Management...68 4.24 Using the Session...68 4.25 Relationship of PortletSession with HttpSession...70 4.26 Session Usage Example...70 4.27 End of Portlet Life...71 4.28 Portlet Configuration...71 4.29 Initialization Parameters...72

4.30 Portlet Context...72 4.31 Invoking the View Layer...73 4.32 Controller Logic Implementation Techniques...74 4.33 Review Questions...75 4.34 Review Answers...76 4.35 Summary...76 Chapter 5 - Portlet Preferences...77 5.1 Portlet Preferences...77 5.2 Portlet Preferences API...78 5.3 Example: Reading Preferences...79 5.4 Updating Portlet Preferences...79 5.5 Example: Updating Preference...81 5.6 Validating Preference Update...82 5.7 Example Validator Class...82 5.8 Review Questions...83 5.9 Review Answers...84 5.10 Summary...84 Chapter 6 - Display Generation...85 6.1 Techniques in View Development...85 6.2 PortletRequestDispatcher include/forward Details...85 6.3 JSR 286 Tags...87 6.4 The defineobjects Tag...87 6.5 The defineobjects Tag...88 6.6 Example defineobjects Usage...88 6.7 The actionurl Tag...89 6.8 The renderurl Tag...90 6.9 The param Tag...90 6.10 The namespace Tag...90 6.11 National Language Support...91 6.12 Resource Bundle File...91 6.13 Displaying Translated Text...92 6.14 Portlet Resource Bundle...93 6.15 Providing Locale Specific Preference Defaults...94 6.16 Review Questions...94 6.17 Review Answers...94 6.18 Summary...95 Chapter 7 - Advanced Programming Topics...97 7.1 JSR 286 Annotations...97 7.2 @RenderMode...97 7.3 @ProcessAction Annotation...98 7.4 Setting the Action Name in URL...99 7.5 Portlet Caching...99 7.6 Basic Caching Setup...100 7.7 Programmatic Cache Control...100 7.8 Validation Based Caching...101 7.9 Validation Caching API...101

7.10 Example Validation Control...102 7.11 Summary...103 Chapter 8 - Portlet Services...105 8.1 Portlet Services...105 8.2 Writing a Portlet Service...105 8.3 Defining the Portlet Service Interface...106 8.4 Example - AccountService...106 8.5 Writing the Portlet Service Implementation...107 8.6 java.util.prefs.preferences...107 8.7 Example AccountServiceImpl...108 8.8 Registering Portlet Services...109 8.9 WAS Admin Console PortletServiceRegistryService...109 8.10 Using a Service from a Portlet...110 8.11 Example Using a Service...110 8.12 Content Access Service...111 8.13 Content Access Service...112 8.14 Summary...112 8.15 Review Questions...112 8.16 Review Answers...112 Chapter 9 - Portlet Communication Overview...115 9.1 Portlet Communication Techniques...115 9.2 Comparison of Portlet Communication Techniques...116 9.3 Comparison of Portlet Communication Techniques...117 9.4 Comparison of Portlet Communication Techniques...118 9.5 Which Portlet Communication Technique Should I Use?...118 9.6 Which Portlet Communication Technique Should I Use?...119 9.7 Summary...120 Chapter 10 - Portlet Event...121 10.1 Portlet Events...121 10.2 Event Architecture...122 10.3 Example Use Case...123 10.4 Event Flow Sequence...123 10.5 Sequence Diagram...124 10.6 Defining an Event in portlet.xml...125 10.7 Using Default Namespace...125 10.8 Creating the Payload Class...126 10.9 Publishing an Event...126 10.10 Consuming an Event...127 10.11 Consuming an Event...128 10.12 The @ProcessEvent Annotation...128 10.13 Details about @ProcessAction...129 10.14 Additional Notes About Events...129 10.15 Portlet Event Configuration...130 10.16 Summary...130 Chapter 11 - Public Render Parameter...131 11.1 Public Render Parameters...131

11.2 Example Use Case...132 11.3 Steps to Using Public Render Parameters...132 11.4 Define Public Render Parameter in portlet.xml...133 11.5 Declare Public Render Parameter for a Portlet...133 11.6 Setting Value of a Public Render Parameter...134 11.7 Example Setting Public Render Parameter...135 11.8 Getting Value of a Public Render Parameter...135 11.9 Additional API...136 11.10 Limitations...136 11.11 Summary...136 Chapter 12 - Client-side Click-to-Action Portlet Communication...137 12.1 Client-side Click-to-Action ("Live Text")...137 12.2 Example Use Case...137 12.3 Example Use Case...138 12.4 Specify a Live Text Source...139 12.5 Specify a Live Text Source Example...139 12.6 Specify a Live Text Target...140 12.7 Specify a Live Text Target - Example...141 12.8 Looking Underneath the Hood...142 12.9 Looking Underneath the Hood...143 12.10 Summary...143 Chapter 13 - Developing JSF Portlets for WebSphere Portal...145 13.1 What is JavaServer Faces (JSF)?...145 13.2 Why Use JSF?...145 13.3 Nature of a JSF Application...146 13.4 JSF and MVC...147 13.5 JSF and MVC...148 13.6 Faces Servlet...148 13.7 Managed Bean...149 13.8 The View...150 13.9 A Simple JSF Application...151 13.10 The Input Form: form.jsp...152 13.11 The Result: thanks.jsp...153 13.12 The Controller: AddressBean...153 13.13 Page Flow or Navigation Rule...154 13.14 How Does the Application Work?...154 13.15 How Does the Application Work?...155 13.16 Creating a JSF Portlet...156 13.17 Creating a JSF Portlet...157 13.18 Creating a JSF Portlet...157 13.19 Navigation State Management...158 13.20 Advanced: Obtaining Core JSF Objects...158 13.21 JSF 2.0 and Portlets 2.0...158 13.22 Summary...159 Chapter 14 - Web Services for Remote Portlets...161 14.1 Remote Portlets...161

14.2 WSRP...161 14.3 WSRP Terminology...162 14.4 WSRP Benefits...163 14.5 WSRP Architecture...163 14.6 Information Artifacts...164 14.7 Security Issues...164 14.8 JSR-286 and WSRP 2.0...164 14.9 Pre-defined Container Events...165 14.10 Pre-defined Container Events...166 14.11 Summary...166 Chapter 15 - Using AJAX in a Portlet...167 15.1 What is AJAX?...167 15.2 A Simple Example...168 15.3 The Old Way...169 15.4 The AJAX Way...170 15.5 Two Key Aspects of AJAX...170 15.6 Advantages of the AJAX Approach...171 15.7 The Basic AJAX API...171 15.8 Creating the XMLHttpRequest Object...172 15.9 The XMLHttpRequest Object Basics...172 15.10 Complete Example...173 15.11 The Timeline...175 15.12 Using AJAX from a Portlet...175 15.13 JSR-286 and AJAX...176 15.14 The ResourceServingPortlet Interface...176 15.15 Output From serveresource()...176 15.16 ResourceURL...177 15.17 AJAX Request Timeline...178 15.18 Steps to be Taken by a Portlet...178 15.19 A Complete Example...179 15.20 The View JSP...179 15.21 The Portlet Class...180 15.22 Summary...180 Chapter 16 - The Dojo Toolkit...181 16.1 Introduction...181 16.2 Installation...182 16.3 Dojo Capabilities...183 16.4 Simple Example Tab Widget...183 16.5 Simple Example Tab Widget...184 16.6 How Does DOJO Work?...184 16.7 Importing Packages...185 16.8 Widget Basics...186 16.9 Widget Basics...186 16.10 Widget Layout Example...187 16.11 The Two byid() Methods...188 16.12 Widget Properties...188

16.13 Widget Events...189 16.14 Common Features of Widgets...190 16.15 Form Input Widgets...190 16.16 The Button Widget...191 16.17 The Checkbox Widget...191 16.18 The ComboBox Widget...192 16.19 The ComboBox Widget...193 16.20 The ComboBox Widget...193 16.21 The ComboBox Widget...194 16.22 The FilteringSelect Widget...195 16.23 The FilteringSelect Widget...196 16.24 The FilteringSelect Widget...196 16.25 The FilteringSelect Widget...197 16.26 The DateTextBox Widget...199 16.27 Layout Widgets...199 16.28 Other Common GUI Widgets...200 16.29 Creating Widget Instances Programmatically...200 16.30 Creating Widgets Programmatically...201 16.31 Summary...202 16.32 Review Questions...202 16.33 Review Answers...202 16.34 Review Answers...203 Chapter 17 - Using Dojo in WebSphere Portal 8.0...205 17.1 Dojo and WebSphere Portal 8.0...205 17.2 Dojo and AJAX Portlets...205 17.3 Dojo Versions in WebSphere Portal 8.0...206 17.4 Dojo Best Practices...206 17.5 Dojo Support in RAD 8.5 New Project...208 17.6 Dojo Support in RAD 8.5 New Project...209 17.7 Dojo Support in RAD 8.5 Existing Project...209 17.8 Dojo Tools in RAD 8.5...209 17.9 Generated Dojo Code in RAD 8.5...210 17.10 Generated Dojo Code in RAD 8.5...211 17.11 Summary...211 Chapter 18 - Spring MVC Portlets...213 18.1 Portlets...213 18.2 Portlets...213 18.3 Portlets...214 18.4 Spring Portlet MVC Framework...215 18.5 Spring MVC and Portlet Configuration...217 18.6 Spring Required JARS...217 18.7 Configuring Spring Portlet MVC Framework...218 18.8 Configuring Spring Portlet MVC Framework...218 18.9 Spring Portlet Views...219 18.10 Spring Portlet Handler Mappings...220 18.11 Mapping on Render Parameters...221

18.12 Mapping on Render Parameters...222 18.13 Handling Portlet Actions...222 18.14 Session Attributes...223 18.15 Global Session...224 18.16 JSR-286 Resource Serving...225 18.17 JSR-286 Events...225 18.18 Summary...226 Chapter 19 - Developing WebSphere Portal Themes and Skins...227 19.1 Changes in WebSphere Portal 8.0 Themes...227 19.2 Theme and Skin Concepts...228 19.3 Using WebDAV to Access Theme Files...228 19.4 Creating a Custom Theme...229 19.5 Customizing the New Theme...229 19.6 Important Styles...230 19.7 Dynamic Content Spot...230 19.8 Configuring Dynamic Content Spot...231 19.9 Developing a Theme as an EAR File...232 19.10 Developing a Theme as an EAR File...232 19.11 Registering Themes Deployed as an EAR...233 19.12 Registering Themes Deployed as an EAR...233 19.13 WebSphere Portal Tag Libraries...234 19.14 Using WebSphere Portal Tag Libraries...235 19.15 Managing Themes and Skins...235 19.16 Module Theme Framework...236 19.17 Summary...237 Chapter 20 - WebSphere Portal Personalization Framework...239 20.1 Overview of Personalization...239 20.2 Overview of Personalization...240 20.3 Presenting the Personalized Content...240 20.4 Presenting the Personalized Content...241 20.5 Creating a Personalization Rule...242 20.6 Personalization Campaigns...242 20.7 Personalization Campaigns...243 20.8 Content Spots...243 20.9 Content Spots...243 20.10 Personalization JAR Files...244 20.11 Personalization Resources...244 20.12 Personalization Resources...245 20.13 Personalization Portlets...246 20.14 Personalization Rules...246 20.15 Personalization Rules...247 20.16 Personalization Rules Process Flow...247 20.17 Summary...248 Chapter 21 - Portlet Build and Deployment Process...249 21.1 Introduction...249 21.2 Overview of the Build Process...250

21.3 The Build Process...250 21.4 Installing a Portlet Web Module...251 21.5 How is a Portlet Web Module Installed?...252 21.6 How is a Portlet Web Module Installed?...253 21.7 Deploying Portlets Within an EAR...253 21.8 Managing Portlet Web Modules...254 21.9 Managing Portlet Web Modules...255 21.10 Managing Portlet Applications...255 21.11 Managing Portlet Applications...256 21.12 Managing Portlets...256 21.13 Managing Portlets...257 21.14 Adding a Portlet to a Page...258 21.15 Configuring a Portlet...258 21.16 Copying a Portlet Application...259 21.17 Copy a Portlet...259 21.18 Removing a Portlet From a Page...259 21.19 Uninstalling a Portlet Application...260 21.20 Summary...261 Chapter 22 - iwidget Portlet...263 22.1 Introduction to iwidget...263 22.2 iwidget Portlets...263 22.3 Anatomy of an iwidget...264 22.4 Creating an iwidget...265 22.5 The iwidget Editor...266 22.6 Developing the Business Logic...266 22.7 Lifecycle Callback Methods...267 22.8 Firing an Event...267 22.9 Consuming an Event...268 22.10 Wiring...268 22.11 Summary...269 Chapter 23 - Portal Development Best Practices...271 23.1 Architecture Best Practices...271 23.2 Controller (Portlet) Guidelines...272 23.3 Controller (Portlet) Guidelines...273 23.4 Controller (Portlet) Guidelines...273 23.5 View (JSP) Guidelines...274 23.6 View (JSP) Guidelines...275 23.7 View (JSP) Guidelines...276 23.8 Configuration Management...277 23.9 Session Management...277 23.10 Security Guidelines...278 23.11 Java Performance Tips...278 23.12 Portlet Performance Tips...279 23.13 Performance Testing Guidelines...279 23.14 Summary...280

Chapter 1 - Introduction to WebSphere Portal Server Objectives Key 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 An IBM Definition 1.1 What is a Portal 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.

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, realtime 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

Chapter 1 - Introduction to WebSphere Portal Server 1.3 General Portal Architecture Vertical Consumer Portal B2B Portal Employee Portal Customer Portal Horizontal Administration, Page generation, Collaboration, Publish & Subscribe, Search & Navigation, Personalization, Integration,... 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

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

Chapter 1 - Introduction to WebSphere Portal Server 1.5 A Typical Network Architecture for WebSphere Portal Web Server Router Internet WebSphere Portal Server Public Network Authentication Server DMZ LDAP Server 1.6 WebSphere Portal Server Internal Network DB 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

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. Authentication Proxy 1.7 WebSphere Portal Server Architecture Trust Association Interceptor WebSphere Portal Server Portlet Container User Interface Portlet Engine Portal Service WebSphere Application Server Security LDAP Portal Configuration Database 18

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

Chapter 1 - Introduction to WebSphere Portal Server 1.9 WebSphere Portal Server Architecture WebSphere Portal Server Access Control Portal Servlet Page Aggregation Portlet Container/ Portlets LDAP User Bean WebSphere Portal Server Architecture Portal Registry Portal Configuration Database Services 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

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

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

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

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

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

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

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

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. What is a Portal? General Portal Architecture WebSphere Portal Products WebSphere Portal Architecture Basic Portlet Concepts 1.23 Summary 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

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

Chapter 2 - Portlet Development Using Rational Application Developer 8.5 Objectives Key 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.

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

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-developmode-startup-performance Portal 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

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

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

Chapter 2 - Portlet Development Using Rational Application Developer 8.5 Create a Project Structure 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 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

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

Chapter 2 - Portlet Development Using Rational Application Developer 8.5 Enter the WebSphere administrator user ID and password. Click Next 2.11 Create a Test Portal Server Enter the Portal administrator user ID and password (usually wpsadmin). Click Finish. 38

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

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

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

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? 1. Portlet and Portal Tools 2.18 Review Answers 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

Chapter 3 - Introduction to JSR 286 Based Portal Programming Objectives Topics 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

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

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

Chapter 3 - Introduction to JSR 286 Based Portal Programming 3.5 A Portal Site Header Area Page Sidebar Portlet A Portlet B Portlet Portlet C Footer Area A Portal Site Submit 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

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

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/portletapp_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

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

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