Professional Documents
Culture Documents
04 Apr 2007 Get an overview of WebSphere Portal in this basic tutorial, which includes both demos and hello world exercises. This tutorial includes two practical exercises. You will develop and test your first portlet using Rational Application Developer with the WebSphere Portal Test Environment. Then, you'll deploy your portlet in a production environment using WebSphere Portal.
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 1 of 41
developerWorks
ibm.com/developerWorks
develop and test a portlet in a development environment, and then deploy the portlet in a production environment.
System requirements
To complete Exercise 1: Develop and test a portlet in a development environment, install Rational Application Developer V7. During the installation, check the option to install the feature Portal tools to get the WebSphere Portal test environment.. For Exercise 2: Deploy a portlet in a production environment, you need WebSphere Portal V6. You can download a free, trial version of WebSphere Portal Express V6 at no cost.
Section 2. Introduction
What is WebSphere Portal?
IBM WebSphere Portal is a framework that includes a runtime server, services, tools, and many other features for integrating your enterprise into a single, customizable interface called a portal. A portal is a Web site that provides users with a single point of access to resources and services. A portal built with IBM WebSphere Portal 6.0 offers a single point of personalized interaction to resources and services, including applications, content, people, and business processes. Figure 1 shows a high level view of the architecture. Figure 1. IBM WebSphere Portal architecture
ibm.com/developerWorks
developerWorks
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 3 of 41
developerWorks
ibm.com/developerWorks
A portal page contains one or more portlets. Portal Web site A portal Web site is built with portal pages. Portal server runtime The execution environment for the portlets. Also called the portlet container, it is a J2EE application that runs on WebSphere Application Server. Portlet versus servlet Portlets can be administered while the Portal Server is running (for example, Install/Remove portlet application, Create/Delete portlets, portlet settings). This is more dynamic than servlets. Portlets may not send errors directly to browsers, forward requests, or write arbitrary markup to the output stream. In WebSphere Portal, go to Portlet Specification for JSR 168 > Relationship with the Servlet Specification for details. Portal page layout The page layout defines the number of content areas within the page and the portlets displayed within each content area. Themes Themes represent the overall look and feel of the portal, including colors, images, and fonts. Skins Skin refers to the visual appearance of the area surrounding an individual portlet. Each portlet can have its own skin. See Resources for more information.
Key features
Customers can choose one of the three WebSphere Portal Multi-platform offerings: WebSphere Portal Server, WebSphere Portal Enable, and WebSphere Portal Extend. WebSphere Portal Server is the foundation offering that provides: The Portal framework Core portal functions WebSphere Portal Enable adds: Web content management
ibm.com/developerWorks
developerWorks
Document management Workflow WebSphere Portal Extend adds: Workplace forms Collaborative services
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 5 of 41
developerWorks
ibm.com/developerWorks
WebSphere Portal provides key functions to support SOA applications, as shown in Table 1 below. See Resources for more information. Table 1. WebSphere Portal functions that support SOA applications
Function Accessing Web Services from portlet Web Services for Remote Portlet (WSRP) Description Rational Application Developer provides tools to easily create a portlet to call a Web service. The WSRP standard simplifies the integration of remote applications and content into portals. With WSRP, portal administrators can select from a rich choice of remote content and applications and integrate them into their portal with a few mouse clicks and no programming effort.
ibm.com/developerWorks
developerWorks
WebSphere Portal supports the integration of your existing business processes and applications into the portal. Portals are the ideal interface for the human component of business processes. WebSphere Portal supports the portlets created by the WebSphere Portlet Factory. WebSphere Portlet Factory speeds WebSphere Portal deployments by automating portlet development. It provides an SOA entry point for companies by delivering SOA-based portal applications. WebSphere Portal Version 6.0 simplifies working with composite applications, enabling integration of information from multiple applications, and providing end users with the content they need based on their role and task.
Composite applications
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 7 of 41
developerWorks
ibm.com/developerWorks
In Exercise 2, you take the role of the WebSphere Portal administrator to put MyFirstPortlet live in a production environment. You will first install MyFirstPortlet in WebSphere Portal, then customize the look and feel of the portlet. Finally, you will grant permission to a new user to use the portlet.
1.
From Windows, click Start > Programs > IBM Software Development Platform > IBM Rational Application Developer > Rational
ibm.com/developerWorks
developerWorks
Application Developer. 2. A window opens asking for the workspace directory. Click OK to accept the default.
3.
In the Portlet Project wizard, enter MyFirstPortlet for the Project name. The EAR Project Name and Portlet name are auto-filled by the wizard upon your entry of Project name. For Target Runtime, choose WebSphere Portal v6.0. For Portlet API, choose JSR 168 Portlet. For the Portlet type, choose Basic Portlet. Click Next. Figure 6. New Portlet Project features
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 9 of 41
developerWorks
ibm.com/developerWorks
4.
Accept the default values in the Portlet Settings panel, as shown in Figure 7, and click Next. Figure 7. Portlet Settings
ibm.com/developerWorks
developerWorks
5.
As shown in Figure 8, select the check boxes for Add action listener and Add JSP form sample in the Action and Preferences panel. Click Next. Figure 8. Action and Preferences
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 11 of 41
developerWorks
ibm.com/developerWorks
6.
In this exercise, you will not be using single sign-on. Accept the default values in the Single Sign On section, as shown in Figure 9, and click Next. Figure 9. Advanced Settings
ibm.com/developerWorks
developerWorks
7. 8.
Click Finish. Observe that the MyFirstPortlet Project you just created was generated in the Project Explorer pane. Figure 10. Project Explorer
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 13 of 41
developerWorks
ibm.com/developerWorks
Explore the files in your MyFirstPortlet project, and review the purpose of each file using Table 2 below. You will be modifying these files to create your own customized portlet. Table 2. Portlet files at a glance
File web.xml Purpose One of the two deployment descriptors required for portlets. It provides information to the server about all non-portlet resources. The other deployment descriptor required for portlets. It provides information to the server about all portlet related resources. A Java file containing the method doView() which is the first method that is executed when a portlet renders. When a user interacts with the portlet (such as selecting the Submit button), the method processAction() is called to process the user action that occurs. The session bean is used to pass data to the JavaServer Pages (JSP) files. The view JSP file is used to edit the display of a portlet in View mode. (In Portal, there is also Edit mode and Help mode.)
portlet.xml
MyFirstPortlet.java
MyFirstPortletSessionBean.java MyFirstPortletView.jsp
ibm.com/developerWorks
developerWorks
Session beans are used to pass data to the JSP. In this step, create two new variables called myName and greeting to store the user's name and greeting message. 1. In Project Explorer expand MyFirstPortlet > Java Resources: src > com.ibm.myfirstportlet and double click the file MyFirstPortletSessionBean.java, as shown in Figure 11. Figure 11. MyFirstPortletSessionBean.java file
2.
Delete all the class variables and methods from the MyFirstPortletSessionBean class, and create new private Strings for myName and greeting. The SessionBean class should now look like as follows.
package myfirstportlet; public class MyFirstPortletPortletSessionBean { private String myName = ""; private String greeting = ""; }
3.
Right-click in the MyFirstPortletSessionBean window and select Source > Generate Getters and Setters, as shown below. Figure 12. Generate Getters and Setters
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 15 of 41
developerWorks
ibm.com/developerWorks
4.
Check the boxes for the variables greeting and myName, as shown in Figure 13. This wizard generates the getters and setters for both variables. Click OK. Figure 13. Select Getters and Setters to create
ibm.com/developerWorks
developerWorks
5.
You can see errors in the other classes. Don't worry, you will fix these errors later.
2.
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 17 of 41
developerWorks
ibm.com/developerWorks
code you need to type in. To reduce the chances of making an error, focus on the items in bold in the code below. Change the variable FORM_TEXT to FORM_NAME Create a new variable similar to FORM_TEXT called FORM_GREETING Change the if statement to also check if the strings stored sessionBeans are empty As you type, you can also use the Code Assist (Ctrl-Space) function to help complete the keywords.
<%@ page session="false" contentType="text/html" import="java.util.*,javax.portlet.*, myfirstportlet.*" %> <%@taglib uri="http://java.sun.com/portlet" prefix="portlet" %> <portlet:defineObjects/> <% MyFirstPortletPortletSessionBean sessionBean = (MyFirstPortletPortletSessionBean)renderRequest.getPortletSession().getAttribute (MyFirstPortletPortlet.SESSION_BEAN); %> <DIV style="margin: 12px; margin-bottom: 36px"> <% String formName = sessionBean.getMyName(); String formGreeting = sessionBean.getGreeting(); if( formName.length()>0 && formGreeting.length() > 0) { %> '<%=formName%>' wants to wish you '<%=formGreeting %>'. <% } %> <FORM method="POST" action="<portlet:actionURL/>"> <LABEL for="<%=MyFirstPortlet.FORM_NAME%>">Enter Your Name:</LABEL><BR> <INPUT name="<%=MyFirstPortlet.FORM_NAME%>" type="text"/><BR> <LABEL for="<%=MyFirstPortletPortlet.FORM_GREETING%>">Greeting:</LABEL><BR> <INPUT name="<%=MyFirstPortlet.FORM_GREETING%>" type="text"/><BR> <INPUT name="<%=MyFirstPortlet.FORM_SUBMIT%>" type="submit" value="Submit"/> </FORM> </DIV>
3.
ibm.com/developerWorks
developerWorks
com.ibm.myfirstportlet and double click the file MyFirstPortlet.java. 2. Modify the code, as shown below. Add the FORM_NAME and FORM_GREETING variable. Delete the variable FORM_TEXT (this variable was part of the generated sample code).
public public public public public static static static static static final final final final final String String String String String VIEW_JSP = "MyFirstPortletPortletView"; SESSION_BEAN = "MyFirstPortletPortletSessionBean"; FORM_SUBMIT = "MyFirstPortletPortletFormSubmit"; FORM_NAME = "MyFirstPortletPortletFormName"; FORM_GREETING = "MyFirstPortletPortletFormGreeting";
4.
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 19 of 41
developerWorks
ibm.com/developerWorks
2.
Ensure that MyFirstPortlet is listed in the Configured Projects pane. If it is not, highlight MyFirstPortlet and click Add >, as shown below. Click Finish. Figure 15. Add MyFirstPortletEAR to PTE
ibm.com/developerWorks
developerWorks
In the Servers pane, observe that MyFirstPortlet is added to the WebSphere Portal v6.0 server @localhost. Figure 16. Servers
4.
Start the WebSphere PTE on your local machine. From Servers, right-click WebSphere Portal v6.0 Server and click Publish, as shown below. This starts the WebSphere Portal v6.0 server, and publishes the MyFirstPortlet to the server. It might take a few minutes to complete this step. Figure 17. Start the PTE
When the WebSphere PTE has started and the MyFirstPortlet is published, an indication in Servers in the Status section appears. Figure 18. PTE start status
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 21 of 41
developerWorks
ibm.com/developerWorks
6.
You can test the MyFirstPortlet on the WebSphere PTE right here in your local development environment. Right-click WebSphere Portal v6.0 Server in Servers and choose Open Portal. Figure 19. Open Portal
MyFirstPortlet is launched in the IBM WebSphere PTE window in Rational Application Developer. Figure 20. MyFirstPortlet launched in PTE
ibm.com/developerWorks
developerWorks
8.
Test the portlet by typing in your name, and a special greeting for a special someone. Since April first just passed, type in Happy April Fool's Day!. In Enter Your Name, type your name. In Greetings, type Happy April Fool's Day. Click Submit. Figure 21. Testing MyFirstPortlet in PTE
Observe that the greeting is displayed in your portlet. Figure 22. MyFirstPortlet displays a message
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 23 of 41
developerWorks
ibm.com/developerWorks
10. Click Submit again in the form. Leave both text boxes blank this time. What happens? 11. Stop the Portal Test Server. Right-click WebSphere Portal v6.0 Server and select Stop.
ibm.com/developerWorks
developerWorks
2.
In Destination, browse to a directory of your choice, as shown in Figure 24. Select the check box for Export source files, and click Finish. Figure 24. Export WAR file to specified destination
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 25 of 41
developerWorks
ibm.com/developerWorks
To start the service on Windows, click Start > Settings > Control Panel > Administrative Tools > Services > IBM WebSphere Application Server V6 WebSphere_Portal_ ...
ibm.com/developerWorks
developerWorks
<hostname> is the fully qualified host name of the machine that is running WebSphere Portal, and <port_number> is the port number (it is displayed on the confirmation panel during your install). For example, http://www.ibm.com:10038/wps/portal 2. Log in using your WebSphere Portal administrator user ID and password.
2.
In the left pane, select Portlet Management > Web Modules. Click Install on the Manage Web Modules page. Figure 26. Manage Web Modules
3.
The Installing a Web Module wizard appears, as shown in Figure 27. Browse to the directory where you exported the MyFirstPortlet.war file from Exercise 1 of this tutorial, or where you downloaded the MyFirstPortlet.war from the Downloads section. Figure 27. Installing a Web Module
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 27 of 41
developerWorks
ibm.com/developerWorks
4. 5.
In Step 2 of the wizard, review the portlet application that is going to be installed. Click Finish. Once the installation is complete, a message indicates the installation was successful at the top of the page, as shown below. MyFirstPortlet.war now appears in the list of Web modules shown on the page. Figure 28. Portlet successfully installed
ibm.com/developerWorks
developerWorks
2. 3.
In the Manage Pages window, select Context Root, then Home. Locate the Welcome page in the list (it should be first) and click the Edit Page Layout button corresponding to this page. By clicking , you can edit the layout of the page. Figure 30. Manage Welcome Page
4.
Add MyFirstPortlet to the top right in the Welcome page by clicking on Add Portlets in the right column in the layout. Figure 31. Edit Layout
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 29 of 41
developerWorks
ibm.com/developerWorks
5.
A search screen renders on the page to let you search for the portlet you want to add. As shown in Figure 32, type MyFirstPortlet in the Search text box. Figure 32. Edit Layout search window
6.
In the search results, select the MyFirstPortlet check box and click OK. Figure 33. Edit Layout search results
7.
MyFirstPortlet portlet appears in the right column of the layout page. Figure 34. Edit Layout with MyFirstPortlet added
8.
To further customize the Welcome page, move MyFirstPortlet to the top of the right column. Click the Move portlet up button to move the portlet up on the page until it appears at the very top of the column.
ibm.com/developerWorks
developerWorks
9.
Click Done.
10. At the bottom left of the page, click Home, as shown below, to exit the Administration pages and go to the Welcome page. Figure 35. Go to Welcome Page
11. MyFirstPortlet appears at the top right. Figure 36. MyFirstPortlet added to Welcome Page
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 31 of 41
developerWorks
ibm.com/developerWorks
2.
In the Manage Pages window, locate the Welcome page in the list (it should be first) and click the Edit Page Layout button corresponding to this page. By clicking , you'll be able to edit the page, including the appearance. Select Appearance in the upper left corner. You can see the layout of the Welcome page. In the MyFirstPortlet box, select Thin Skin as the skin, as shown below. Click Done. Figure 37. Appearance portlet
3.
4.
Exit the Administration pages by clicking Home at the bottom-left corner. Notice that the skin of MyFirstPortlet has now changed, as shown in Figures 38 and 39 below. Figure 38. MyFirstPortlet using Default Skin
ibm.com/developerWorks
developerWorks
5.
2. 3.
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 33 of 41
developerWorks
ibm.com/developerWorks
4.
Click OK. A message is displayed saying the user was created successfully. Figure 41. User created successfully in Portal
5. 6.
Log in to Portal using the newly created user John. Do you see MyFirstPortlet on the Welcome page? MyFirstPortlet is not on user John's Welcome page. When you installed the MyFirstPortlet in WebSphere Portal, you did not grant any users with access permission to the portlet. That is why you can only view the portlet as the administrator. No other users can view MyFirstPortlet in the Welcome page at this point. Exit WebSphere Portal by clicking Log out in the upper-right corner.
7.
ibm.com/developerWorks
developerWorks
MyFirstPortlet
1. 2. 3. 4. Log in to WebSphere Portal as the Administrator again. Select Administration on your right. Select Access > Resource Permissions. In the Resource Permissions page, as shown below, click Portlets. Figure 42. Resource Permissions Portlet
5.
Enter MyFirstPortlet as the search criteria. Click Search. Figure 43. Search for MyFirstPortlet in Resource Permissions
6.
Click the Assign Access button displayed beside the MyFirstPortlet resource. Figure 44. Assign access to MyFirstPortlet
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 35 of 41
developerWorks
ibm.com/developerWorks
7.
Click the Edit Role button beside the Role User. Figure 45. Modify Access for a Role
8.
There are currently no members in this role, as shown below. This explains why you weren't able to see MyFirstPortlet when you logged in as a user that is not an administrator (for example, John). Figure 46. Members with access are shown
9.
Click the Add button, as shown above, to add members to this role.
10. Select the All Authenticated Portal Users check box. Click OK. Figure 47. Give access to all Authenticated Portal Users
ibm.com/developerWorks
developerWorks
11. Log out of Portal, and log in as a user that is not an administrator. For example, John. Figure 48. Log in as a user
12. What do you see in the Welcome Page? Figure 49. MyFirstPortlet accessible to all users
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 37 of 41
developerWorks
ibm.com/developerWorks
ibm.com/developerWorks
developerWorks
Downloads
Description
Sample for the exercises in this tutorial Information about download methods
Name
Size
Download method
HTTP
MyFirstPortlet.war10KB
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 39 of 41
developerWorks
ibm.com/developerWorks
Resources
Learn New to WebSphere Portal provides a high level overview of WebSphere Portal. IBM WebSphere Portal Business Solutions: This catalog has news, information about solutions, samples, demos, and much more. Read the JSR 168: Portlet Specification. Gartner: Magic Quadrant for Horizontal Portal Products, 2006: Learn more about the horizontal portal product market. Opening the door to a service oriented architecture IBM Workplace, Portal and Collaboration products for an SOA. SOA describes SOA services and products from IBM. Learn more about the IBM SOA Foundation. One of IBM Redbooks, IBM Rational Application Developer V6 Portlet Application Development and Portal Tools, provides an overview and hands-on scenarios to help you design, develop and implement portlet applications using Rational Application Developer V6.0 and the provided Portal Tools. Read about the OASIS Web Services for Remote Portlet (WSRP) technical committee, which is standardizing presentation-oriented Web services for use by aggregating intermediaries, such as portals. The IBM WebSphere Portal Version 6.0 Information Center explains How WSRP works. "Architecting on demand solutions, Part 18: Use IBM WebSphere Integration Developer to assemble components" (developerWorks, Feb 2006) explains how to set up human tasks, business process integration, and security. IBM WebSphere Portlet Factory: Read about the features and benefits. A Portal May Be Your First Step to Leverage SOA: This Gartner Management Update explains that to implement a service-oriented architecture (SOA), companies must consider what steps and technologies are involved. Portals represent a logical first step in the process. Get products and technologies Download a free, trial version of Rational Application Developer V7 to use with this tutorial. Download a free, trial version of WebSphere Portal Express V6 to use with this tutorial. Download IBM product evaluation versions and get your hands on application development tools and middleware products from DB2, Lotus, Rational, Tivoli, and WebSphere.
ibm.com/developerWorks
developerWorks
Discuss Participate in the discussion forum for this content. Check out developerWorks blogs and get involved in the developerWorks community.
Janet Lee Janet joined IBM full time after graduating with a Bachelor of Applied Science in Computer Engineering degree from the University of Waterloo. She has previously worked at various IBM software functions within the Toronto IBM Software lab, including the DB2 Regression team and the Java Just-in-Time Compiler Development team. Janet is currently a part of Software Group Strategy, Scenario Analysis Lab, where she is implementing a customer-based scenario named the Employee Workplace, using various IBM products such as DB2 Content Manager, DB2 Document Manager, DB2 Records Manager, WebSphere Information Integrator OmniFind Edition, and WebSphere Portal.
Trademarks
WebSphere Portal V6 Copyright IBM Corporation 1994, 2007. All rights reserved.
Page 41 of 41