JSR-168 Portlets and uPortal Matt Young

Slides:



Advertisements
Similar presentations
Struts Portlet Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Advertisements

Apache Struts Technology
A Blackboard Building Block™ Crash Course for Web Developers
11 Getting Started with ASP.NET Beginning ASP.NET 4.0 in C# 2010 Chapters 5 and 6.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
Starting with Gridsphere Albert Einstein Institute Gridsphere Installation.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Indianapolis Java User Group JSR-168 Portal Presentation Introduction: Kurt Desserich.
UPortal: A framework for the Personalization of Library Services John Fereira: Programmer/Analyst Cornell University Mann Library.
Java Portlets (JSR-168) SSE USTC Qing Ding.
Tutorial 3: Adding and Formatting Text. 2 Objectives Session 3.1 Type text into a page Copy text from a document and paste it into a page Check for spelling.
ECE356 – Database Systems Lab 1 – Building a Web Project with NetBeans Tiuley Alguindigue Lab Instructor – University of Waterloo, E & CE Dept. Fall 2013.
Portals and portlets Sean C. Sullivan October 24, 2006 Portland Java Users Group.
1 Agenda Overview Review Roles Lists Libraries Columns.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
UNIT-V The MVC architecture and Struts Framework.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Ashish jaiman architect evangelist Microsoft
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
1 Servlet How can a HTML page, displayed using a browser, cause a program on a server to be executed?
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Server-side Scripting Powering the webs favourite services.
The EPIKH Project (Exchange Programme to advance e-Infrastructure Know-How) Hostname-portlet Template Riccardo Rotondo
Indianapolis Java User Group Portal Presentation - Part 2 Introduction: Kurt Desserich.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
Design Patterns Phil Smith 28 th November Design Patterns There are many ways to produce content via Servlets and JSPs Understanding the good, the.
Guidelines for Homework 6. Getting Started Homework 6 requires that you complete Homework 5. –All of HW5 must run on the GridFarm. –HW6 may run elsewhere.
INDIVIDUAL ACHIEVEMENT. EDUCATIONAL EXCELLENCE. ADMINISTRATIVE INNOVATION. INSTITUTIONAL PERFORMANCE. 1 Develop and Deploy JSR-168 Portlets Presented by:
Chapter 7 Java Server Pages. Objectives Explain how the separation of concerns principle applies to JSP Describe the operation and life-cycle of a JSP.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
Michelle Osmond & Yike Guo All Hands Meeting September 2005 Adopting and Extending Portlet Technologies for e-Science Workflow Deployment The Discovery.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
Rendering Contexts and Components What is a uPortal3 context ? –Defines all aspects of a traditional portal instance Design, navigation, profiles Parameter.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Portlets in uPortal uPortal Domain Objects Portlet Application Deployment Portlet Deployment –Information from portlet.xml file Portlet Application Definition.
CHEF II / Sakai Architecture. CHEF II Changes uPortal replaces Jetspeed –jsr 168 portlet, servlet compliant Spring replaces Turbine component framework.
Running Kuali: A Technical Perspective Ailish Byrne - Indiana University Jay Sissom - Indiana University Foundation.
1 ® Copyright 2009 Adobe Systems Incorporated. All rights reserved. Adobe confidential. 1 Building Portlets with ColdFusion Pete Freitag Foundeo, Inc.
J2EE Overview Web Programming CSCI J2EE multi-tier architecture Servlet: Java class loaded into Web server JSP page: enhanced HTML page that is.
Module 10 Administering and Configuring SharePoint Search.
Java Portals and Portlets Submitted By: Rashi Chopra CIS 764 Fall 2007 Rashi Chopra.
Application Specific Module Tutorial Akos Balasko 02/07/
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
JSR 168 Overview Copyright © 2000 – 2007 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Portlets 1.
Struts Framework Anna Paščenko. What is Struts?  An open source framework for building Java web applications.
Using Ajax to Improve uPortal User Experience Jen Bourey Yale University
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Java Enterprise Edition Programming Page 1 of 9Configuring Servlets Web Application Context Name  In multiple web applications, a “context name” is used.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
Portals: Architecture & Best Practices Greg Hinkle February 2005.
The Jetspeed Portal Bluesunrise.com and The Apache Software Foundation January 28, 2002 From
Rendering Syndicated Library Content in an Institutional Portal: Integrating MyLibrary into uPortal John Fereira: Cornell University Eric Lease Morgan:
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Module 5: Managing Content. Overview Publishing Content Executing Reports Creating Cached Instances Creating Snapshots and Report History Creating Subscriptions.
Apache Struts Technology A MVC Framework for Java Web Applications.
Apache Cocoon – XML Publishing Framework 데이터베이스 연구실 박사 1 학기 이 세영.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Tutorial on Science Gateways, Roma, Riccardo Rotondo Web Application Development Introduction to application servers, web applications and portlets.
Introduction to portlet development Carla Carrubba INFN Dpt. Of Catania Giuseppina Inserra
Portals: Background, Development & Conversion
Working in the Forms Developer Environment
Sri Vatsav Konreddy CIS 764 FALL 2007
Create a Portlet Project in RAD
Developing a Model-View-Controller Component for Joomla
Presentation transcript:

JSR-168 Portlets and uPortal Matt Young

Goals Familiarity with portlet architecture Familiarity with the services provided to portlets by the spec Ability to write useful portlets Provide examples that can be used as a cut & paste source for common tasks Explore MVC options

Overview What’s a portlet? What is its relationship with a portal? How is it deployed on a web server? What deployment descriptors does it need? How is the code laid out? What services does it provide?

What is a Portlet? A portlet produces an HTML fragment that populates a window (or channel) within a portal page The portlet can communicate with the portal container

Portals and Portlets Portal Tomcat Application Server Portlet App Weather Portlet Search Portlet Events Calendar Portlet Search Controller Portlet Search Results Portlet Pluto

uPortal and Portlets uPortal Tomcat Announcements Channel UBC Webmail Application Server RSS Feed Weather Portlet Wrapper Search Portlet Wrapper Event Cal. Portlet Wrapper Pluto Weather Portlet Search Portlet Events Calendar Portlet

uPortal Announcements Channel UBC Webmail RSS Feed Weather Portlet Wrapper Search Portlet Wrapper Event Cal. Portlet Wrapper

A Portlet in uPortal Weather Portlet Wrapper (an instance of CPortletAdapter) edu.duke.oit.ows.portlets.WeatherPortlet

The Portlet Pieces Source Code portlet.xml web.xml

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" " Hello World Portlet

portlet.xml <portlet-app xmlns=" version="1.0" xmlns:xsi=" xsi:schemaLocation=" HelloWorldPortlet edu.duke.oit.ows.HelloWorldPortlet 0 text/html EDIT HELP Hello World Portlet

When changing portlet.xml You’ve got to restart uPortal for the changes to show up, even after a re- deployment! I will forget to do this at least once today

Portlet source code Extend GenericPortlet (or other portlet class, like JSPPortlet) Override one or more standard methods: doView, doEdit, doHelp, processAction

Portlet Modes View: The default portlet mode, providing the standard UI for the portlet Edit: A mode for setting user-configurable preferences Help: Displays help for using the portlet Modes can be specified on a per mime-type basis Custom modes can be defined by the portal to provide more modes

Window States NORMAL: A regular window MAXIMIZED: A window taking up the entire content space of the portal page MINIMIZED: Just the title bar of the portlet Custom window states make also be defined by the portal EXCLUSIVE: uPortal adds this mode to facilitate file uploads

processAction The processAction method is called when the portlet receives an action. This is where any logic that the portlet provides should be tripped, including storing/updating preferences

Call sequence

About the init method It is not safe to assume that the portlet is in an active portal container until the init method is called. Therefore, make no attempt to access services from the constructor of the portlet or in any location before the init method is called

Hello World Portlet

Deploying the Portlet Step 1: User uPortal ant target ‘deployPortletApp’ to deploy application to the server ant deployPortletApp -DportletApp= Step 2: Configure uPortal to see the portlet as a channel Portlet Defintion ID: warFileName.portletName

Notes about Portlet Deployment If you do something wrong, uPortal is likely to cache the error. Best to restart in a development environment to make sure deployment descriptors are correct Deployment happens just like a regular web app, except that the ant task alters the web.xml file to make it usable by uPortal

Creating an action First, generate an actionURL PortletURL actionURL = response.createActionURL(); Then, actionURL.toString() will provide the URL that will trip a processAction call. Parameters can be added to the actionURL (or any other PortletURL) with actionURL.setParameter(String name, String value);

Changing Modes VIEW / EDIT / HELP are default modes To change modes, generate an action URL: PortletURL actionURL = renderResponse.createActionURL(); This calls the processAction method when followed, then, within the processAction method, set the appropriate destination mode: actionResponse.setPortletMode(PortletMode.EDIT);

Modes and uPortal buttons EDIT -> EDIT HELP -> HELP

Portlet Parameters Parameters can be set within the portlet.xml file so that compiles are not required to move portlets from installation to installation There are 2 kinds of parameters, init- params and portlet-preferences

init-param Initialization parameters (ie. Site dependant constants) specified in portlet.xml defaultZipCode Readable from a PortletConfig object available in all init methods String zipCode = config.getInitParameter(“defaultZipCode”);

portlet-preferences When defined within the portlet.xml file, these are default values for the per-user runtime preferences Preference values may be set as read-only Essentially a variable initialization mechanism for runtime user preferences

User Preferences Each portlet can use the portal’s data store to hold on to per-user preferences To read in preferences: PortletPreferences prefs = request.getPreferences(); To read a particular named preference: prefs.getValue(String pref_name, String default); The above will return default if there is no preference named pref_name for that user, otherwise the value of that preference will be returned

User Preferences The getValue() method returns a String The getValues() method returns a String[] Preferences are read-only in all the “do” methods Preferences are read-write in the processAction method

User Preferences To store preferences: PortletPreferences prefs = actionRequest.getPreferences(); prefs.setValue(“nickname”, “Matt”); prefs.store(); Values are not committed until the store() method of PortletPreferences is called User preferences should not be used as a general purpose database. The intent is only to hold portlet preferences (settings) Use JNI or another method for getting a database handle if larger scale db operations are needed

User Attributes Some basic security attributes are available from the request object: request.getAuthType() <-- returns a constant request.getRemoteUser() <-- login ID request.getUserPrincipal() <-- returns user principal request.isUserInRole(String) <-- role (group) checking request.isSecure() <-- https? (or equivalent?)

User Attributes Portlets can be granted access to the user attributes available in the portal framework In uPortal terms, these are the attributes defined in the PersonDirs.xml file Available attributes must be defined in the portlet.xml file (JSR-168) spec in addition to the PersonDirs.xml file (uPortal)

User Attributes Attribute values can be retrieved in the portlet from the USER_INFO map returnable from a renderRequest or actionRequest Map userInfo; userInfo = request.getAttribute(PortletRequest.USER_INFO); String uniqueID = userInfo.get("uniqueID");

Caching uPortal caches portlet content until the portlet receives and action or a render request. This means that the ‘reload’ button will not update content in portlets. Only interaction with the portlet will cause an update This turns out to be a useful mechanism for reducing load on external resources It also keeps portal response very fast

Better display options Keeping your (X)HTML in the portlet code is not optimal. Best practice is to separate logic from view. Some options for a better View technology:  JSP  JSF  XSLT  Spring (in beta - coming soon, example in the CVS repository for uPortal)

Request Dispatchers You can use a PortletRequestDispatcher to send the PortletRequest onto another rendering service First obtain the request dispatcher from the portletContext: PortletRequestDispatcher rd = getPortletContext.getRequestDispatcher(“/MyPortletView.jsp”); Then, include the current request and response so that parameters can be seen by the.jsp (or JSF, or other rendering service): rd.include(request,response);

CSS Standards The JSR-168 spec lists standard CSS class names for use within portlets Adhering to these names is suggested. uPortal will most likely adopt these standards See Appendix C of the JSR-168 spec

Request Attributes Request attributes can be used to send data to JSPs or other rendering technology: request.setAttribute(“name”, “Matt”); In the JSP this attribute can be retrieved with:

Response Properties Properties can be added to the PortletResponse: response.setProperty(“expiration-cache”, 0); The above is a useful property to set if there’s an exception thrown in the Portlet

What doesn’t uPortal implement? The portlet title, usually read from a parameter in portlet.xml or a resource bundle, is defined in the channel definitions Expiration cache has no meaning within uPortal - update: just added User elements accessed via a portlet must be defined both in portlet.xml and PersonDirs.xml

What does JSR-168 miss? Inter-portlet communication

“Trick” Inter-portlet communication A portlet application is a collection of individual portlets User the PortletSession available from a PortletRequest to transport attributes between portlets within a portlet application

Inter-portlet Communication Since the processAction method is guaranteed to run first, make any state changes there first: PortletSession ps = actionRequest.getPortletSession(); ps.setAttribute(“zip”, zip, PortletSession.APPLICATION_SCOPE); The SCOPE specified in the setAttribute method allows the attribute to be seen on either the Portlet level or the Portlet Application level

Inter-portlet Communication Attributes can be retrieved from the session in the “do” methods of a portlet: PortletSession ps = renderRequest.getPortletSession(); String zip = (String)ps.getAttribute(“zip”);

Inter-portlet Communication Caution! There’s no guarantee of execution sequence of doView, doEdit methods of the portlets on a portal page Some “do” methods may not be fired because of the caching paradigm being applied to that portlet There is no guarantee that a user might delete one essential part of a portlet app without removing the others, so something like Aggregated Layouts would have to be used

Resources