Develop a personalized portlet
This exercise demonstrates how to use Personalization features of WebSphere Portal and Rational Application Developer to build your first personalized portlet. Your final result is a working portlet that uses Personalization rules and content spots to display personal news based on user attributes (or profiles).
The final portlet looks like the following example:
The demonstration Web site is organized into the following three pages:
- Front Page
Internal News Displays internal YourCo news for the user. This portlet displays the news upon clicking upon one of the links General News Displays external worldwide news articles for users. This portlet messages to the GeneralNewsDetails upon clicking upon one of the links UserInfo Displays the current user's information. This information is used in rules to target content throughout the website to the particular preferences of your users. This user information can be modified using the edit feature.
- Partners Page
Products Displays products for the current user. This portlet messages to the PartnersDetails upon clicking upon one of the links. Promotions Runs a simple rule targeting the information in the portlet to the user's preferences.
The promotions portlet also demonstrates running a campaign and the splitting of rules within a campaign. In this case, between March 1 and April 16, 2005 the Tax Season campaign will run. Within this campaign, one content spot is filled with 2 distinct rules, Get Tax Season Promotions and Get 3 Promotions about IRAs. Get Tax Season Promotions will be run 70% of the time and Get 3 Promotions about IRAs the remaining 30%.
A second campaign is also running in the promotions spot between April 14 and April 15, 2005. This campaign has a higher priority than the Tax Season campaign so it will run at this time.
- Services Page
- Services displays services that are offered to the user. Clicking on one of the services will display the details of the service. If logging is enabled, clicking on one of the services will log the fact that this particular type of service was selected by the user.
- Offers displays current offers for the user. This portlet demonstrates calling an analysis bean from a rule.
Personalization can use database content. This exercise uses the sample database that comes with the Personalization sample. The following tables are used:
- PZN_USER: contains user information, including profile attributes
- PZN_OFFERS: contains text for special offers categorized by customer type
FIRST_NAME LAST_NAME DEPARTMENT CUSTOMERTYPE USERNAME* Scott Green Loans Gold scott Tawana Streble HR Platinum tawana Marge Roorda HR Platinum marge Andy McPherson IT Titanium andy
Table 2. Sample data from PZN_OFFERS table (primary key = OFFER_ID) OFFER_ID* CUSTOMERTYPE TITLE DETAILS 1 Platinum 2nd House Mortgage Excellent Mortgage rates on your beach house. 2 Gold Add other Cards Add other members of your household to your account. 3 Platinum ARM Mortgage 1/3 5.9% APR Mortgage for 27 years. 4 Titanium Free Checking Deluxe Free Checking with the attainment of a YourCo Financial Credit Card. Notice the common element in these tables is the column CUSTOMERTYPE. This column is important when you invoke Personalization later in the exercise.
- Prerequisites for the Personalization portlet exercise
This exercise is intended for users with significant WebSphere Portal administration experience and strong portlet Java development skills.- Install the Personalization sample and database
This exercise installs the sample Portal Personalization Apache Derby database. No additional database requirements are needed.- Create the JSP file in Rational Application Developer
Create a basic JSR 168 portlet file for the Personalized Offers project and add the welcome text to the portlet.- Create the Personalization content resource classes and content spot
- Create the Personalization user resource classes and content spot
Use the Project Explorer of IBM Rational Application Developer to create the user resource classes and content spot for the Personalization demo that creates the Personalized Offers portlet for different customer profiles.- Finish coding the portlet JSP
Use the Rational Application Developer Project Explorer to work with the pers_offers.Pzn_offersSpot.class and the pers_offers.Per_Offers_UserSpot.class to define the context parameters offersSpot and the userSpot, respectively. Code the setRequest calls to pass the user context to personalization.- Export the WAR file and install the portlet
- Import Personalization Workspace resource collections
Use the Personalization Navigator to create Workspace folders for the resource collections. Then import the resource collections into the Workspace of the Personalization Navigator.- Create a simple content rule
Use the Personalization Editor to create a business rule for a resource collection.- Create a content spot
Use the Personalization Editor to create a placeholder for the rule that renders the selected content on a Web page. This placeholder is the content spot. Specify which rule to place in the content spot; this is called mapping the rule to the content spot or creating a rule mapping. In this example, the content is a resource collection.- Enhance the Personalized Portlet
- Insert dynamic table html/jsp code
Use Rational Application Developer to code the dynamic table in the Personalized Offers portlet JSP. Export the project as a Web archive (WAR) file. Open the WebSphere Portal Administration page for Portlet Management and update the Web module containing the Personalized Offers portlet.- Modify resource collection properties
Use the Personalization Navigator to specify the Translator Class for the resource collection.- Create the user profiler rule
Use the Personalization Editor to create a profiler rule for users who qualify as customers for Gold Offers in the Personalized Offers resource collection.- Create additional advanced rules
For each customer type specified by a profile, add to the business rule (the profiler) by selecting actions to build the syntax of the rule.- Change content spot rule mapping
Change the default rule mapping to the new binding rule that you created for different customer types who will use the Personalized Offers portlet. Test the portlet for use by all customer types. Verify that the portlet displays the personalized content specified by the business rule for each user profile.- Personalized List portlet
The Personalized List portlet provides a ready-to-use portlet for displaying personalized content from rules, content spots, or resources. In many cases it eliminates the need to code new portlets and JSP files yourself. Use this portlet instead of coding the IBM Rational Application Developer portlet.- Uninstall Personalization sample and database
Parent topic
Use rules