Building Portals with the Java Portlet API

418 566 4
Building Portals with the Java Portlet API

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Building Portals with the Java Portlet API

Java Portlet APIBuilding Portalswith thethis print for content only—size & color not accurate spine = 0.790" 416 page countEMPOWERING PRODUCTIVITY FOR THE JAVA DEVELOPERBuilding Portals with the Java Portlet APIDear Reader,How do you bring your existing applications into the portal? How do you inte-grate your content management system and search engine with the portal?How do you get started with the portlet API? We show you how to solve realproblems, like the ones we have seen as consultants and software developers.We cover the portlet API in depth, explaining the concepts and classes withexample scenarios and code. When you are comfortable with the portlet API,we examine portal integration techniques, Single Sign-On, content manage-ment, charting, personalization, application and content syndication, andsearching.We believe that with the remarkable cooperation in unifying the portlet APIacross many different vendors, using standards for portals is now the bestchoice. Our examples will therefore run on any portal that supports the portletAPI. We avoid proprietary tools, instead showing how to incorporate severalopen source software projects into your portlets, including XDoclet, ApacheJakarta Lucene, and JFreeChart.Our backgrounds as developers and consultants lead us to look for booksthat concentrate on solving real problems with new technologies, not justexplaining their details. We hope that this book will help you to solve problemsusing the portlet API.Jeff Linwood and Dave MinterJeff Linwood, co-author ofPro Struts ApplicationsUS $49.99Shelve inJavaUser level:Intermediate–Advancedwww.apress.comSOURCE CODE ONLINEforums.apress.comFOR PROFESSIONALS BY PROFESSIONALS™Join online discussions:Linwoodand MinterTHE EXPERT’S VOICE®IN JAVAJeff Linwoodand Dave MinterForeword by Ian GriffithsBuildingPortals with theJava Portlet APICYANMAGENTAYELLOWBLACKPANTONE 123 CVISBN 1-59059-284-09 781590 59284754999689253 158401Learn how to create portlet applications, integrate existing webapplications, and incorporate XDoclet, Apache Jakarta Lucene,JFreeChart, and other open source projectsDave MinterBeginningJava ObjectsEnterprise Java Development on a BudgetBeginning J2EE 1.4Beginning JSP 2Building Portals with the Java Portlet APIAPRESS JAVA ROADMAPIncludesPluto, Lucene,and XDocletIncludesPluto, Lucene,and XDoclet Praise for Building Portals with the Java Portlet API :“The book gives a solid introduction to developing a portal . . .Clearly the authors understand portal development and know howto pass that information on to their readers.”—Thomas Paul, JavaRanch (www.javaranch.com)“The text is well written and easy to read; graphics and illustrationsare used sparingly and to great effect.”— Jack Herrington, Code Generation Network (www.codegeneration.net)Download at Boykma.Com Building Portals withthe Java Portlet APIJEFF LINWOOD, DAVE MINTER2840chFM.qxd 7/13/04 12:43 PM Page iDownload at Boykma.Com Building Portals with the Java Portlet API Copyright © 2004 by Jeff Linwood, Dave MinterAll rights reserved. No part of this work may be reproduced or transmitted in any form or by anymeans, electronic or mechanical, including photocopying, recording, or by any informationstorage or retrieval system, without the prior written permission of the copyright owner and thepublisher. ISBN (pbk): 1-59059-284-0Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1Trademarked names may appear in this book. Rather than use a trademark symbol with everyoccurrence of a trademarked name, we use the names only in an editorial fashion and to thebenefit of the trademark owner, with no intention of infringement of the trademark.Lead Editor: Steve AnglinTechnical Reviewer: Carsten ZiegelerEditorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Tony Davis,John Franklin, Jason Gilmore, Chris Mills, Steve Rycroft, Dominic Shakeshaft, Jim Sumser,Karen Watterson, Gavin Wray, John ZukowskiProject Manager: Kylie JohnstonCopy Edit Manager: Nicole LeClercCopy Editor: Liz WelchProduction Manager: Kari BrooksProduction Editor: Ellie FountainCompositor: Kinetic Publishing Services, LLCProofreader: Nancy SixsmithIndexer: James MinkinArtist: Kinetic Publishing Services, LLCCover Designer: Kurt KramesManufacturing Manager: Tom DebolskiDistributed to the book trade in the United States by Springer-Verlag New York, Inc., 175 FifthAvenue, New York, NY 10010 and outside the United States by Springer-Verlag GmbH & Co. KG,Tiergartenstr. 17, 69112 Heidelberg, Germany.In the United States: phone 1-800-SPRINGER, e-mail orders@springer-ny.com, or visithttp://www.springer-ny.com. Outside the United States: fax +49 6221 345229, e-mailorders@springer.de, or visit http://www.springer.de. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219,Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visithttp://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although everyprecaution has been taken in the preparation of this work, neither the author(s) nor Apress shallhave any liability to any person or entity with respect to any loss or damage caused or alleged tobe caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.comin the Downloadssection.2840chFM.qxd 7/13/04 12:43 PM Page iiDownload at Boykma.Com Contents at a GlanceForeword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiAbout the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiiiAbout the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xivAcknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xviiChapter 1 Introduction to Portals and Portlets . . . . . . . . . . . . . . 1Chapter 2 Portlet Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Chapter 3 The Portlet Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Chapter 4 Portlet Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73Chapter 5 Using Servlets and JavaServer Pages with Portlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119Chapter 6 Packaging and Deployment Descriptors . . . . . . . . . . . . 159Chapter 7 Portal and Portlet Configuration . . . . . . . . . . . . . . . . 185Chapter 8 Security and Single Sign-On . . . . . . . . . . . . . . . . . . . . . . 209Chapter 9 RSS and Syndication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239Chapter 10 Integrating the Lucene Search Engine . . . . . . . . . . . 255Chapter 11 Personalization and User Attributes . . . . . . . . . . . . . 281Chapter 12 Web Services for Remote Portlets (WSRP) and Application Syndication . . . . . . . . . . . . . . . . . . . . . . 295Chapter 13 Exposing an Existing Application As a Portlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307Chapter 14 Charting with JFreeChart . . . . . . . . . . . . . . . . . . . . . . . . . 339Chapter 15 Content Management Systems . . . . . . . . . . . . . . . . . . . . . . . 359Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381iii2840chFM.qxd 7/13/04 12:43 PM Page iiiDownload at Boykma.Com 2840chFM.qxd 7/13/04 12:43 PM Page ivDownload at Boykma.Com ContentsForeword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiAbout the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiiiAbout the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xivAcknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xviiChapter 1 Introduction to Portals and Portlets. . . . . 1Providing a Solution with Portals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Designing the Portal’s Information Architecture . . . . . . . . . . . . . . . . 2Portal Application Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Building Portlets with the Portlet API . . . . . . . . . . . . . . . . . . . . . . . . . . 6Providing Technical Solutions with Portals . . . . . . . . . . . . . . . . . . . . . . 7Security and Single Sign-On . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Content Syndication and RSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Searching Content from the Portal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Portals and Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Integrating Existing Applications into the Portal . . . . . . . . . . . . . . 9Using Charts in the Portal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Content Management and Portlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Chapter 2 Portlet Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11First Portlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Building the Portlet Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Deploying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Running . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Portlet Programming 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21GenericPortlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Portlet Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Portlet Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Enhancing the Portlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Web.xml Deployment Descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37v2840chFM.qxd 7/13/04 12:43 PM Page vDownload at Boykma.Com Packaging and Deploying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38Running . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40Chapter 3 The Portlet Life Cycle. . . . . . . . . . . . . . . . . . . . . . . 41The Portlet Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Creation of the Portlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Request Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47Destroying the Portlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Threading Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71Chapter 4 Portlet Concepts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73Portlet Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73Render Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Action Request and File Uploading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Portlet Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85Render Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86Action Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Portlet Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98Sessions and Interportlet Communication . . . . . . . . . . . . . . . . . . . . . . . 102Content Markup Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105Portlet Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107Window States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116Style Sheets and the User Experience . . . . . . . . . . . . . . . . . . . . . . . . . . 116Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117Chapter 5 Using Servlets and JavaServer Pages with Portlets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119Portlets, Servlets, and JSP Design Goals . . . . . . . . . . . . . . . . . . . . . . 119Portlet Request Dispatcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120Request and Response Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126Session Management Between a Portlet and a Servlet or JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131Creating a Form in JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132Using the Portlet JSP Tag Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132To-Do List Portlet Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137Contentsvi2840chFM.qxd 7/13/04 12:43 PM Page viDownload at Boykma.Com The web.xml Deployment Descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153Directory Structure of the Application . . . . . . . . . . . . . . . . . . . . . . . . 153Complete Code Listing for the To-Do List Portlet . . . . . . . . . . . . 154Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158Chapter 6 Packaging and Deployment Descriptors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159Portlet Application Packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159Versioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159Portlet Application Deployment Descriptor Structure . . . . . . . . . 160Web Application Deployment Descriptor . . . . . . . . . . . . . . . . . . . . . . . . . 170XDoclet Portlet Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184Chapter 7 Portal and Portlet Configuration. . . . . . . . . 185Using the PortalContext to Retrieve Information About the Portal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185Using the PortletConfig Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190Using Portlet Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208Chapter 8 Security and Single Sign-On. . . . . . . . . . . . . . . 209Portlet Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238Chapter 9 RSS and Syndication. . . . . . . . . . . . . . . . . . . . . . . . . . 239Overview of RSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239Walking Through an Example RSS File . . . . . . . . . . . . . . . . . . . . . . . . . . 240RSS Browsers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246Displaying Syndicated Information in Portlets . . . . . . . . . . . . . . . . 247Syndicating Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253Chapter 10 Integrating the Lucene Search Engine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255Overview of Lucene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255Downloading and Installing Lucene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256Contentsvii2840chFM.qxd 7/13/04 12:43 PM Page viiDownload at Boykma.Com Lucene Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256Building an Index with Lucene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263Designing a Portlet to Search the Index . . . . . . . . . . . . . . . . . . . . . . . 270Developing a Portlet for Lucene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271Indexing Other Types of Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277Lucene and Different Types of Content . . . . . . . . . . . . . . . . . . . . . . . . . 279Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280Chapter 11 Personalization and User Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281Making a Good Impression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281Making Choices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294Chapter 12 Web Services for Remote Portlets (WSRP) and Application Syndication. . . . . . 295WSRP Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295WSRP and the Java Portlet API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298WSRP Markup in Content Fragments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299Using WSRP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304Common Problems with Application Syndication . . . . . . . . . . . . . . . . . 304Future Directions of WSRP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306Chapter 13 Exposing an Existing Application As a Portlet. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307Overview of the YAZD Forum Software . . . . . . . . . . . . . . . . . . . . . . . . . . . 307Deciding What to Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309Displaying Screens in a Portlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312Getting Configuration Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332Issues Encountered in Our Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338Chapter 14 Charting with JFreeChart. . . . . . . . . . . . . . . . . . . . 339Building Charts and Graphs with JFreeChart . . . . . . . . . . . . . . . . . . . 339Chart Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340Basic JFreeChart Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343Providing Data to the Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347Contentsviii2840chFM.qxd 7/13/04 12:43 PM Page viiiDownload at Boykma.Com [...]... ( http://maven.apache.org ). Check the Pluto installation instructions to determine which version of Maven to install. 2840ch02.qxd 7/13/04 12:43 PM Page 19 Download at Boykma.Com Chapter 1 6 Building Portlets with the Portlet API Portlets are components written in Java against the portlet API. The Java classes in the portlet API are in the javax .portlet package. Each portlet takes a request from the portal container... inside a portlet in Chapter 5. The portlet container is responsible for sending requests from the portal to the portlet, and then passing the portlet response back to the portal. It also man- ages the initialization of the portlet, along with other life cycle events. The portal is responsible for taking the content from the portal container for each portlet and building a web page for the end user. The. .. includes images in its HTML content. GenericPortlet We are going to use the GenericPortlet class in the javax .portlet package as the base class for all of our portlets. GenericPortlet implements both the Portlet and the PortletConfig interfaces from the portlet API. We have already touched on the Portlet interface, but we will explain the PortletConfig interface in later chapters. 2840ch02.qxd 7/13/04 12:43... use a different base portlet class. Portlets that subclass the GenericPortlet class get implementations of the default functionality for a portlet, which makes developing easier. The portlet will have to override at least one of the methods on the GenericPortlet abstract class to provide the desired functionality. With any upgrade to the portlet API, you should check the GenericPortlet class to see... about the client’s request, access information about the state of the portlet, and query the portlet for details of its configuration from the portlet request object. Two different request objects are used in the portlet API. One is an object that implements the ActionRequest interface, which is an argument to the portlet s processAction() method. The other is a RenderRequest object, which the portlet 2840ch02.qxd... could have portlets in different portlet applications with the same name. It is also possible that you could install the same portlet application on a portal twice, in different contexts. The portal will use a combination of the portlet application context and the portlet name to refer to the portlet. As an aside, you can also have the same portlet in more than one place in the portal page. The <display-name> element... the doView() , doEdit() , and doHelp() methods. The second reason would be to support content display for the minimized window state. Portlet Requests The portlet container passes the portlet request and response objects to the portlet whenever the portlet handles a request. Both the render() and processAction() methods on a portlet take portlet request and response objects as arguments. The portlet. .. similar. The < ;portlet- app> element of the deployment descriptor is the root of the XML document. The root is the container for information about the portlets in the portlet application. It also contains any custom portlet modes, custom win- dow states, user attributes, or security constraints that the portlet application supports. For our first portlet, we are only going to describe a portlet. The. .. sup- ports the Web Services for Remote Portlets (WSRP) standard can display portlets from other WSRP-enabled portals. The producer portal publishes its available portlets to a registry, and a consumer portal can display a remote portlet from the registry. The protocols for displaying a portlet from a remote location were standardized with the WSRP specification from the Organization for the Advancement... any instance of a URL in the portlet s rendered content. Portlets will need to set the content type of the response to one of the allowed content types from the request. Portlets can use the setContentType() method on the RenderResponse object to set the content MIME type: public void setContentType(String type) A portlet can ask the request for the default content type supported by the portal, or it can . MinterBeginningJava ObjectsEnterprise Java Development on a BudgetBeginning J2EE 1.4Beginning JSP 2Building Portals with the Java Portlet APIAPRESS JAVA ROADMAPIncludesPluto,. Boykma.Com Building Portals withthe Java Portlet APIJEFF LINWOOD, DAVE MINTER2840chFM.qxd 7/13/04 12:43 PM Page iDownload at Boykma.Com Building Portals with the

Ngày đăng: 20/08/2012, 11:54

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan