This is Part 1 in a series that will address various topics related to using WebSphere® Personalization (hereafter called Personalization) with WebSphere Portal (hereafter called Portal). In Part 1, we describe how to create a personalized portlet and Web application. In the remaining parts of this series, we will build on the personalized portlet that you will create here in Part 1. Also in this article, we describe WebSphere's rule-based personalization which you will need to understand for future articles. We are writing this series to help you get started; this series is not intended to provide an in-depth understanding of personalization or portals. For further details about personalization and portals, see the references at the end of this article. We have also provided the necessary files to build the database tables used in this example (see the download section below ). In the download ZIP file, we have included the final portlet for those who would prefer to first browse the source, and experiment with the developed portlet.
To build the example in this article, you must have the following software installed on your system. It is important that you have exactly the same software on your machine:
- DB2 © Universal Database Version 7.2, and fixpack 5
- IBM HTTP Server, Version 1.3.19
- WebSphere Application Server, Advanced Edition, Version 4.02
- WebSphere Studio Application Developer Version 4.03
- WebSphere Personalization wizards for WebSphere Studio Application Developer 4.0
- WebSphere Portal 4.11 or 4.12
- WebSphere Personalization 4.1
- WebSphere Portal Toolkit for WebSphere Studio Application Developer
- Operating system: Windows 2000
We recommend that you use the WebSphere Portal Setup Manager to install the above software.
WebSphere Personalization overview
WebSphere Personalization lets developers build Web pages targeted to the site visitors' interests. It lets developers select content suited to the unique needs and interests of a site visitor. Personalization provides easy-to-use Web-based tools to help business users create rules to personalize the content displayed to each unique site visitor.
The three basic components of any personalization solution
-
User profile: Consists of information concerning the site
visitors, including user attributes that you can use to determine what
type of content should be presented to them. Developing a good user
profile is critical to the success of your personalization solution.
-
Content model: Defines the attributes of content that you want
to deliver to your site visitors (for example, product descriptions,
articles, etc.).
In WebSphere Personalization, both user profile and content model are referred to as personalization resources. These resources are implemented as Java classesthat reference either user data or content stored in an external data store. To define a Personalization resource, you need to create Java classes that conform to the WebSphere Personalization API and map to your data store. This API consists of several functions that the Personalization Resource Engine calls at run time to retrieve content selected by a rule. Generate these classes using the User andContent Wizards provided with WebSphere Studio Application Developer (hereafter called Application Developer). In cases where the data store is not a relational database or an LDAP directory, you will have to implement the required API. You can create a resource for any content that you access with Java code, so there is no limitation on the content you can personalize. Any personalization solution should have at least one user resource, and one or more content resources. Once these resources have been created, they need to be published to the Personalization run time, so that rules can reference and use them. You can do this by publishing the resources from Application Developer or by importing them into the Personalization Resource Console.
-
Matching technology: To match each user to the correct content,
you can use filtering, business rules, recommendation engines, or a
combination of all three. All of these methods of matching users to
content are supported by WebSphere Personalization. For the purposes
of this article, we will be using business rules.
Use the Personalization Workspace Rule Composer to create rules. Rules are the business logic that define what content is presented on a Web site as a function of the user accessing it. The rule editors let you create easy-to-read logic statements that utilize information (including user and content resource definitions, the date and time, the request and session objects, and application objects) to determine what action to perform. These actions often involve deciding what content to select, but can also be used to update attributes. To help you personalize your Web site, WebSphere Personalization provides three types of rules: Classifiers, Actions, and Binding rules. The three types of rules are described below:
-
Classifiers are used to divide site visitors into
segments (for example, gold, silver, or bronze) based on
attributes included in the user profile. You can also use
classifiers to classify based on other conditions such as the
current date and time, or data collected through implicit and
explicit profiling. Profiling will be explained further in a
future article. An example of a classifier rule is shown in
the following table. In this example, the classifier
UserClearanceis set toConfidentialif the user's role attribute is eitherManagerorExecutive; otherwise, it is set toRegular.
UserClearance is Confidential when current Personnel.ROLE is equal to Manager or current Personnel.ROLE is equal to Executive Otherwise Regular
-
Actions determine what content can be used to update
values. You can also sort action rules results. Thefollowing
table shows an example of an action rule. This ruleselects
content marked as
confidential.Select Content whose News.CONFIDENTIAL is equal to Y
-
Bindings combine actions and classifiers. In a binding
rule, one or more classifiers are combined with action rules
to form a robust rule. In the following table, the
GetNewsByClearancebinding rule states that if the user's classification isconfidential(for example, the user is classified as such because he or she is either anexecutiveor amanager), then perform thegetConfidentialNewsaction. It also says that theGetSiteNewsrule is always executed. In this example, if the UserClearance is classified as confidential, then the results will be the content returned by the GetConfidentialNews and GetSiteNews rules.When UserClearance is Confidential do GetConfidentialNews Always GetSiteNews order as is show all items
-
Classifiers are used to divide site visitors into
segments (for example, gold, silver, or bronze) based on
attributes included in the user profile. You can also use
classifiers to classify based on other conditions such as the
current date and time, or data collected through implicit and
explicit profiling. Profiling will be explained further in a
future article. An example of a classifier rule is shown in
the following table. In this example, the classifier
WebSphere Personalization development environment
The Personalization development environment consists of the following:
-
WebSphere Studio Application Developer provides wizards via the WebSphere Personalization wizards for Application Developer 4.0 plug-in. It generates your resources if your user or content data is in a relational database or in an LDAP directory. If this data is inany other place, then you will have to implement the Personalization APIs required for that resource. In this case, Application Developerprovides a complete integrated development environment for developing the classes to implement the APIs. Application Developer alsoprovides a wizard for creating content spots, which are placeholders on JSP pages for rules to populate with content.
-
The Personalization workspace is a browser-based tool targeted for business users to help them easily create rules and campaigns, assign rules to content spots, and preview the effect of rules and campaigns on the Web site. The rule editors let you create easy-to-read logic statements that utilize information from user and content resource definitions to determinewhat action to perform (by either selecting content from a data source to deliver to the Web site visitor, or updating stored data).
WebSphere Personalization run-time environment
The Personalization run-time environment consists of the Personalization Server, which is an application server that runs on top of WebSphere Application Server. The main components of the run time are:
- the resource engine
- the rules engine
- the recommendation engine
The basic run-time process consists of the following stages:
- Processing starts when a Web client requests a personalized Web page, which is a JSP page with a content spot.
- The WebSphere Application Server JSP compiler invokes a method on the content spot that in turn calls the rule engine's API to execute the rule.
- Rule processing involves accessing the resources defined to the resourceengine, and retrieving user and content data from the customer data store. The queries to the customer data store are handled by user-provided implementations of the Personalization APIs for accessingresources.
In this section, we describe the personalized portlet you will create. The
example simulates a simple banking news application. The model consists of
two simple tables, Customer and
Customernews . All of the user data is defined
by and stored in the Customer table. The
content model store is the Customernews table.
The visitors to the site are classified based on the balance in their bank
accounts. The classification is as follows:
| Basic | account balance <= 100 |
| Advantage | account balance > 100 and <= 1000 |
| Preferred | account balance > 1000 and <= 10,000 |
| Premium | account balance > 10,000 |
Action rules are defined for each of these classifications. The action rules that will be created as part of this example are:
GetCurrentUser
This action rule returns information about the current user.
GetBasicNews
This action rule selects news that is classified as basic. This news is targeted for customers who are classified as basic (i.e., customers whose balances are less than or equal to 100).
GetAdvantageNews
This action rule selects news whose level attribute is advantage. This news is appropriate for visitors who are classified as advantage (i.e., customers whose balances are between 100 and 1000).
GetPreferredNews
This action rule selects content whose level attribute is preferred. This news is appropriate for visitors who are classified as preferred (i.e., customers who have balances between 1000 and 10,000).
GetPremiumNews
This action rule selects content whose level attribute is premium. This news is appropriate for visitors who are classified as premium (i.e., customers who have balances over 10,000).
To create this sample, complete the following steps:
- Create a portlet application project in Application Developer.
- Create the user and content resources corresponding to the Customer and Customernews table.
- Create the content spots for the rules.
- Create a JSP and add the content spots and corresponding code to the JSPs.
- Publish the resource classes to WebSphere Personalization.
- Create the WebSphere Personalization workspace project.
- Create the rules and associate them with the content spots.
- Publish the project from the Personalization workspace.
- Create the WAR file and deploy the portlet from Application Developer.
- Enroll sample users and view the personalized portlet.
Create the portlet application project in Application Developer
First, create a project in Application Developer using the wizard provided
by the Portal Toolkit. The Portal Toolkit provides a wizard that will
create a project for any of the common portlet types. This is extremely
useful because it generates all of the required files such as
portlet.xml and
web.xml , adds the required JAR files, and sets
up the build classpaths and environment for you in the correct directory
structure. This lets you focus on writing the actual portlet code without
having to worry about the infrastructure. The toolkit also provides the
ability to debug portlets; we will cover this topic in a future article.
Launch WebSphere Studio Application Developer
- Select Start => Programs => IBM Studio Application Developer => IBM Studio Application Developer .
- Select Perspective => Open => Other to launch the Select Perspective window.
- In this window, select Portlet and click OK . You are now ready to create a portlet project.
Create a portlet application project
- Select File => New => Portlet Application
Project to launch the Create a Portlet project Wizard. In the
Project name field, enter
PersSamplePortletHome. Ensure that Use default location is selected. In the Enterprise Application project name field, enterPersSamplePortletEAR. In the Context root field, enterPersSamplePortletHome. See Figure 1 for reference. Click Next .
Figure 1. The initial screen of the Create a Portlet project dialog
- On the next screen, select the Basic Portlet radio button, and click Next . The Create a Portlet project - Basic portlet parameters dialog opens.
- In the Portlet application name field, enter
PersSamplePortletHome application. In the Portlet name field, enterPersSamplePortletHome portlet. In the Concrete portlet application name field, enterPersSamplePortletHome application. In the Concrete portlet name field, enterPersSamplePortletHome application. In the Concrete portlet title field , enterPersSamplePortlet. In the Portlet class name field, enterMyPersSamplePortlet. See Figure 2 for reference. Click Finish .
Figure 2. The Create a Portlet project - Basic portlet parameters dialog
- In the Navigator view, examine the project that you just created. You
should see two folders named
PersSamplePortleEarandPersSamplePortletHome, with a directory structure that resembles Figure 3.
Figure 3. The portlet project directory structure
Create the user and content resources
Next, create the personalization resources using the Application Developer Personalization Wizards. Every personalized portlet must have a user resource and one or more content resources. The user resource describes attributes of the user currently logged into Portal. The content resources describe attributes of the content that you want to personalize. This information is used by personalization rules to match the right content with the right user.
Ensure the Personalization Wizards appear in the Portlet Application Developer view
If you do not see the Content Spot, Content, and User Wizards in the Application Developer toolbar, you can add them by completing the following steps. Refer to Figure 5 below to see what the icons look like.
- Select Perspective => Customize .
- Expand the Other folder, as shown in Figure 4, and select the
Personalization Wizards check box.
Figure 4. Adding the Personalization Wizards to your perspective
- Create a folder under the source folder named,
PersSamplePortlet. - Highlight the PersSamplePortlet folder, and select the User
Wizard icon, as shown in Figure 5.
Figure 5. Launching the User Resource Wizard
- The first screen of the Personalization User Wizard opens. In the
Protocol field, select Database (SQL) . In the Database URL,
enter
jdbc:db2:sample. In the User ID field, enterwsdemo, and in the Password field, enterwsdemo1. Ensure that IBM DB2 UDB local is selected as the Driver identifier, and accept all other defaults. Then, click Connect . See Figure 6.
Figure 6. The User Wizard Logon page
- When the connection completes successfully, a new set of notebook tabs appears.
- Click the Tables tab. Select the CUSTOMER table from
the Available tables listed on the left, and then add it to the
Selected tables list by pressing the > button. This is
the primary table for the user resource.
Figure 7. The User Wizard Tables tab view
- Click Next to go to the Columns page.
- Click the >> button on the Columns page to select all of the columns in this table. If this table had many columns, you would want to be selective about which columns you pick. Select only if you need to write rules that use a particular column's values in deciding which rows should be part of the result set, or need to display the column as part of the rows in the result set.
- Click the Finish tab. Note the names of the source files that the wizard generates.
- Click the Finish button.
Figure 8 highlights all of the files that are generated by the User
Wizard. Notice that the source files are compiled and placed in the
appropriate directory within the project.
Figure 8. The User Wizard output
To create a content resource using the Content Wizard, complete the same steps that you used to create a user resource. Launch the wizard by selecting the Content Wizard icon in the toolbar (to find the correct icon, position your cursor over the icons to see the hover help text). Make sure that you select the Customernews table as your content resource. Figure 9 shows the files that the Content Wizard generates.
Figure 9. The Content Wizard output
Obtain the short form of the LDAP user ID
Once the Application Developer Wizards have generated the Java files for
the resources, you must make some minor modifications. This step is
necessary when using Personalization with Portal, and security is enabled.
When you use Personalization outside of Portal, it is your responsibility
to tell the Personalization run time who the current user is by setting
pzn.userName in the personalization context.
However, when security is enabled, the Personalization run time does not
use pzn.UserName . Instead, the user name is
obtained from LDAP. Unfortunately, this value is the fully qualified user
ID in LDAP's Distinguished Name (DN) syntax. For example, the name will be
of the format,
user:foosball.raleigh.ibm.com:389/uid=user1,cn=users, dc=raleigh,dc=ibm,dc=com
. To identify the current user, the Personalization run time simply needs
the user ID, which in this case is user1 .
Therefore, you need to strip out all of the extra information or the
Personalization run time will never get a match for the user ID. To do
this, you could write a translator class and register it through the
Resource Console; for the purposes of this sample, we will take a shortcut
and do it a different way:
-
Add the following method to the
CustomerManager.javafile:
/* translateAuthID removes all the extra stuff that gets attached as part of the dn */ public String translateAuthID (String name) { /**** if ldap, set to uid ****/ /***** find uid= *******/ System.out.println("The name that has been passed is : " + name); String delim = new String("uid="); int x = name.indexOf(delim); /****** find comma **********/ String comma = new String(","); int y = name.indexOf(comma, x); /******* get uid *********/ if ((x >= 0) && (y>=0) ) name = name.substring(x+4,y); System.out.println("*** new name = " + name); return name; }
As you can see, the above method simply strips out the extra characters that are included in the user ID, and then returns the name in the format required by the Personalization run time.
-
Next, update the public Resource findById(String name, ResourceContext context) method in
CustomerManager.javato call the above method.
Add the following code before thetry block:
// Changes needed to strip out the extra ldap stuff System.out.println( "NAME needed to convert : " + name); String translatedName = translateAuthID(name); System.out.println("Translated Name: " + translatedName); name = translatedName; // End of changes
The System.out.println are not required, but adding them will help you understand if your code is working by seeing what is displayed in the log files.
Now that you have defined some resources, you can create content spots using the Application Developer Personalization Content Spot Wizard. Note: To create a content spot, you must first create resources (which you've already done) because you must define what type of content will be used to populate the content spot.
- Select the PersSamplePortlet folder, and then select the
Content Spot Wizard icon.
Figure 10. Launching the Content Spot Wizard
- In the Content Spot Wizard, click the Rule Type tab. Enter
getCurrentUserSpotas the name of the Content Spot Java Bean. In the drop-down menu, select PersSamplePortlet.Customer . See Figure 11.
Figure 11. Completing the Content Spot Wizard
- Click Next , and then click the Finish button. The wizard generates the Java bean wrapper for the content spot.
- Complete the same steps to create a second content spot. Name this
content spot
getCustomernews, and select PersSamplePortlet.Customernews as the return type.
In the navigator window, you will notice that the wizard generated a Java
file for each of the resources:
getCurrentUserSpot and
getCustomernewsSpot .
Add the content spots to the JSP file
Now, add the content spots that you created in the previous step to the View JSP file, and then add code to reference the fields in the content spots that you want displayed.
- Navigate to the
View.jspfile (see Figure 12), and double-click the file to open it in the JSP Editor.
Figure 12. Navigating to the View.jsp file
- Click the Design tab, and erase all of the existing content.
- In the Navigator window, select getCurrentUser.class , hold
the left mouse button down, drag the file to the top of the
View.jspedit window, and drop the file here.An Attributes window opens. Click OK to accept the default values. - Complete the same steps to drag and drop
getCustomernews.classon the JSP. - Click the Source tab of the edit window to view the
useBeantags that were generated when you dropped the content spot class files in the JSP. - Change the
useBeandeclarations as follows (notice that the closing/is removed from theuseBeantag, and that a</useBean>tag is used instead for each of the bean declarations):
The original declaration in your JSP page looks as follows:
<jsp:useBean class="PersSamplePortlet.getCurrentUserSpot" id="getCurrentUserSpot"/> <jsp:useBean class="PersSamplePortlet.getCustomernewsSpot" id="getCustomernewsSpot"/>
Change the above lines to look like this:
<jsp:useBean class="PersSamplePortlet.getCurrentUserSpot" id="getCurrentUserSpot"> <% getCurrentUserSpot.setRequest(request); %> </jsp:useBean> <jsp:useBean class="PersSamplePortlet.getCustomernewsSpot" id="getCustomernewsSpot"> <% getCustomernewsSpot.setRequest(request); %> </jsp:useBean>
The above changes are required for every content spot that you add to a page to link to the WebSphere Personalization run time.
Add code to the JSP to populate the content spots
Now use the JSP Editor to add two tables to the JSP. The tables will eventually be populated with content by a rule. For now, you will associate each table with a content spot. This essentially ties a resource to each table.
Create a table to display user information
- Click the Design tab in the JSP Editor.
- Select Insert => Table to create a new table. Specify 2 rows and 1 column , and then click OK to close the dialog.
- Next, double-click on the table to launch its Attributes dialog.
- Click the Dynamic tab. Refer to Figure 13 below as you
complete this step.
- Select the Loop check box.
- Specify
1for the Start row and2for the End row. - Select the Browse button to launch the Bean Property Selection dialog.
- Select getCurrentUserSpot.ruleContent[] , and click OK .
- Click OK on the Attributes dialog to close it.
Figure 13. The Bean Attributes and Bean Property Selection dialogs
- In the previous step, a resource was associated with the table. Now,
specify which attributes or columns of the resource will be used to
populate the table. Select the first row of the table and enter
"You are logged in as: ". - Position the cursor to the right of the text, and select Insert => Dynamic Elements => Property Display .
- In the Attributes dialog, select Browse to launch the Bean Property Selection dialog.
- This time, select the USERID attribute, and click OK on each of the dialogs to close them.
- Select the second row of the table, and enter
"Your account balance is: ". - Complete the same steps as above, but this time select the
Balance attribute.
Create a table to display personalized news
- Complete
View.jspby adding a second table to the page. Complete steps 2 to 4 from the previous section, but this time specify2for both the start and end rows, and set the loop property asgetCustomernewsSpot.ruleContent[]. Refer to Figure 14 for guidance.
Figure 14. The Bean Property Selection dialog for the second table
- When you have finished with the Bean Property dialog, highlight the
first row of the table, and enter
"Here is your personalized news...". - The second row will contain the news items that are returned. In the first step, you set up a loop on this row, so there will be one row generated for each news item that is returned at run time. Highlight the second row, and then select Insert => Dynamic Elements => Property Display .
- In the Bean Property Selection dialog, select the CONTENT
attribute, and then click OK . See Figure 15.
Figure 15. Selecting the content to display in the table
- Press CTRL-S to save
view.jsp.
Publish the Personalization resource classes
Now that we have created our resources and content spots, we need to create some rules to populate the content spots. Before doing this, you must make the resources known to the Personalization run time. Use the Personalization Resource Console to do this. Note that you can also accomplish the same thing by defining a Publish Server in Application Developer, and then use it to publish the resources. First, export the resources and content spots from Application Developer:
-
Select File => Export => File System .
- Select the following files to export (see Figures 16 and 17 below):
-
The entire
PersSamplePortletHome\webApplication\WEB-INF\classes\PersSamplePortletfolder. -
The entire
PersSamplePortletHome\webApplication\resources\PersSamplePortletfolder.
-
-
For the export destination directory, enter
D:\WebSphere\AppServer\installedApps\Personalization_Runtime.ear\ PersAdmin.war\WEB-INF\classes, whereD:\is the drive on which WebSphere Application Server is installed. -
Click Finish, and if prompted to create the classes directory, select Yes .
Figure 16. Exporting resources
Figure 17. Specifying the export directory
-
Next, make sure that WebSphere Portal is running. If it isn't, then start WebSphere from the Services window, start the WebSphere Administrative Console, and ensure that the Portal Application Server is running before proceeding to the next step.
-
Open the Personalization Resource Console by entering
http://localhost/wps/PersAdmin/adminframe.jspin the address field of a browser window. Substitute your fully qualified host name for the localhost. If prompted for a user ID and password, enterwpsadminandwpsadminrespectively. -
On the Resource Hierarchies tab view, click Import .
-
Enter the file name
D:\WebSphere\AppServer\installedApps\Personalization_Runtime.ear\PersAdmin.war\ WEB-INF\classes\resources\PersSamplePortlet\Customer.hrf, and click Import . Again,D:\represents the drive on which WebSphere Application Server is installed. -
Repeat the previous step to import
Customernewsby pointing to theCustomernews.hrffile this time. Verify that the resources have been importedby going to the Resource Collections tab view. The resources now appear in theCollections drop-down list.
Figure 18. The Personalization Resource Console
Create the News Personalization workspace project
Now, create a project in the Personalization workspace where you can define your rules using the rule editor. First, add a publish server which defines where your rules get published to, and then you will create your project.
-
To launch the Personalization workspace, enter
http://localhost/wps/PersWorkspace/index.jspin your browser. Remember to substitute the fully qualified host name for the localhost. -
Log in to the workspace with user ID,
wpsadmin, and password,wpsadmin, or user ID,wpsbind, and password,wpsbind. -
Click on Global Settings . This launches the Personalization Global Settings window.
Figure 19. Personalization workspace
-
Select Manage Publish Servers , and press the + button on the right side to add a new publish server.
Figure 20. Personalization workspace global settings
-
Enter the values for the publish server, as shown in Figure 21, and click Save . Do not select the Requires authentication check box, and do not enter a user ID and password if security is not
enabled in the portal.
Figure 21. The Add Publish Server dialog
-
Next, create the project. Select Manage Projects , and press + to beginthe process of creating a new project. In the Add Project dialog, select Create new , enter
D:\PersSamplePortletin the Project Path field, and enterPersSamplePortletin the Project Name field (see Figure 22). Then, press OK .
Figure 22. The Add Project dialog
- The Edit Project dialog now opens (see Figure 23).
Figure 23. The Edit Project dialog
Complete as follows (make sure that the drive letters reflect the actual location of the software on your system):- In the Campaign Path field, enter
D:\PersSamplePortlet. - In the Rule Paths field, enter
D:\PersSamplePortlet\Rules. - In the Resource Paths field, enter
D:\WebSphere\AppServer\installedApps\Personalization_Runtime.ear\ PersAdmin.war\WEB-INF\classes\resources\PersSamplePortlet. Note that the.hrffiles of the resource reside here. - In the Resource and Content Spot Class Path field, enter
D:\WebSphere\AppServer\installedApps\Personalization_Runtime.ear\ PersAdmin.war\WEB-INF\classes. Note that the package folder of theresource interface classes resides here. - At this point, you do not need to preview the JSP page, so do not fill out the fields related to Preview. We will cover the topic of previewing in a future article.
- Click Save to exit the dialog.
- In the Campaign Path field, enter
- Finally, press Make Current to activate this project for this
user.
Figure 24. Completing the Personalization global settings
Create the personalization rules
Now, we will create three types of rules:
-
The Classifier rule: We will create the
UserLevelclassifier rule, which classifies the user based on the balance in theiraccount. -
The Action rule: We will create six action rules, the first being
GetCurrentUser, which gets information about the current user. The remaining five action rules get news articles based on the user level that they are suitable for. -
The Binding rule: We will create the
GetCustomerNewsbinding rule, which ties the classifier and action rules together.
Create the UserLevel classifier rule
-
Click the Rule Composer tab. Make sure Classifiers is selected in the drop-down menu,and then press + to create a new rule in the rule composer (see Figure 25).
Figure 25. Invoking the Rule Composer to create a rule
-
Name the classifier,
UserLevel. Notice that the editable fields in the rule body are all hyperlinks. Simply select the hyperlinks one at a time and fill out the resulting dialogs. -
Click on Classification in the rule body, and name this classification,
Basic. -
Click on Resource.Attribute , and select the current Customer resource and BALANCE attribute radio buttons, as shown below in Figure 26.
Figure 26. Selecting a resource and its attribute
-
Select is equal to , and change it to is less than or equal to .
-
Select value , and enter
100. -
Continue adding Classifications until the rule looks like Figure 27 below. Select add Condition when you need to add more than one condition for a classification. Click Save when you are done.
Figure 27. The final UserLevel classifier rule
Create the GetCurrentUser action rule
-
Make sure Actions is selected in the drop-down menu, and press + to create your first action rule. Name it
GetCurrentUser. -
Notice in Figure 28 that you need to select the Specify another attribute radio button, and then press Browse when setting the valuefield. When you save the value, it will change from
Customer.USERIDtocurrent Customer.USERID.
Figure 28. Creating GetCurrentUser
Figure 29. The final GetCurrentUserRule
Create the GetBasicNews action rule
-
Press + to create your next rule. Name the rule
GetBasicNews. - Create the
GetBasicNewsaction rule so that it resembles Figure 30. For this rule and the remainder of the action rules, you need to select the Specify a value of type Text radio button when setting the value field.
Figure 30. The final GetBasicNews
Create the four remaining action rules
Create the remaining four rules:
GetAdvantageNews ,
GetAllNews ,
GetPreferredNews , and
GetPremiumNews . Complete the same steps that
you used to create GetBasicNews . Forexample,
for the GetPreferredNews rule, select the
content whoselevel is set to preferred .
Figure 31. The action rules
Create the GetCustomerNews binding rule
In this rule, you will associate the classifier rule with the actions that you created in the previous steps:
-
Ensure that Bindings is selected in the drop-down menu for the rule types and press + tostart the rule editor. Name the rule,
GetCustomerNews. -
When you click Classifier , a list of available classifiers appears. In ourcase, we have defined only one classifier. Select the UserLevel
classifier.
Figure 32. Selecting a classifier in a binding rule
-
When you click on Classification , you are presented with a list ofclassifications that have been defined for the classifier that you selected in the previous step.
Figure 33. Selecting a Classification .
-
Similarly, click do Action to see a list of all of the actionrules that have been defined. Select the action rule that is most applicable for the classification that you are working with.
-
Complete the
GetCustomerNewsbinding rule as follows:
Figure 34. The GetCustomerNews binding rule
Associate the rules with the content spots
Now, associate the rules you just created with the content spots that you created earlier in this exercise:
-
Click the Campaign Manager tab in the workspace.
-
Select Normal View on the left side.This displays a list of the content spots in this project. Notice that all of the entries in the Rule column are empty.
-
Assign a rule to each of the content spots by clicking on the empty link in the rule column and then selecting a rule from the list of applicable rules. Use Figures 35 and 36 as guides.
Figure 35. The Fill Content Spot dialog with the GetCurrentUser rule selected
Figure 36. The view after assigning rules to content spots
Publish the Personalization project
Now that you have all of your rules defined and assigned to content spots, you can publish the project. This makes the rules available to the Personalization run time.
-
Select Global Settings .
-
Select Publish Files .
-
Make sure that PersPortletServer is selected, and then press Publish .
Export the WAR file from Application Developer
By now, you have finished creating all of the Personalization artifacts and are ready to export your portlet. Return to Application Developer to export the portlet.
-
Right-click the PersSamplePortletHome project in Application Developer, and select Export WAR .
Figure 37. Exporting the WAR file
-
Choose the location you want to export the WAR file to, and click Finish .
Figure 38. Exporting the WAR file details
Deploy and test the portlet in WebSphere Portal
-
To deploy the portlet on WebSphere Portal, enter
http://<YourFullyQualifiedHostName>/wps/myportalin a browser window. -
Log in with user ID,
wpsadmin, and password,wpsadmin. -
Next, install your portlet. Click the Install Portlets tab in the Portal Administration group, and follow the prompts.
-
Add the portlet to the page of your choice.
-
Click the Edit Layout and Content tab in the Work with Pages group.
-
Click Get Portlets .
-
Enter
Persin the Name Contains field, and click Go . -
Click the plus icon next to your portlet to add it to the Portlet list, and then click OK .
-
Select the portlet, and then click the Add portlet to container icon.
-
Click Activate to activate the page.
-
-
Click the Security tab in the Portal Administration group. On this page, grant portlet view access to all authenticated users.
-
Now, you are ready to test your personalized portlet. Before you test it, make sure that you register three user IDs,
user1,user2, anduser3, with the passwords,user1,user2, anduser3respectively. -
Next, log in to the portal with the user ID,
user1. -
Select the page group and the page where you added the portlet. The following page opens displaying details of
PersSamplePortlet:
Figure 39. Portlet output for user1
-
Next, log in as
user2. Notice thatuser2has a balance of1002, and therefore has beenclassified aspreferred. Because of this,user2sees news which is relevant to preferred customers.
Figure 40. Portlet output for user2
In this article, we demonstrated how to develop a simple personalized portlet. Specifically, we showed you how to use the WebSphere Portal Toolkit, and how to extract the short form of the user ID from LDAP; these topics are unique to using WebSphere Personalization with WebSphere Portal. We will explore more advanced topics in future articles.
| Name | Size | Download method |
|---|---|---|
| PersPortalFiles.zip | 72 KB | FTP |
Information about download methods
-
WebSphere Personalization InfoCenter.
Provides fast, centralized information to Personalization information.
-
WebSphere Portal InfoCenter.
Provides fast, centralized information to Portal information.
-
Portlet Catalog.
Hundreds of portlets for you to download and evaluate.
- The WebSphere Studio Application Developer Portal Toolkit Help
documentation (select Portlet developer documentation from the
menu in the Application Developer Help Perspective).
-
Updates to the
InfoCenters.
- Pike, Melissa.
WebSphere Personalization 4.0: Using WebSphere Studio Application Developer Wizards.
IBM WebSphere Developer Technical Journal. May, 2002.
Bruce R. Olson is a member of the WebSphere Enablement team at the IBM Raleigh Lab. Bruce has worked as a consultant on WebSphere products since 1999, specializing in Personalization and Portal. Before joining the WebSphere team, he helped to design and implement the IBM C++ User Interface Class Library. He has coauthored two editions of Power GUI Programming. Before joining the Enablement team, Bruce worked in the IBM Artificial Intelligence Support Center, working with Expert Systems. You can reach Bruce at bolson@us.ibm.com.
Venkata V. (Vishy) Gadepalli is a member of the WebSphere Enablement team at the IBM Raleigh Lab. He has over five years experience in the IT field. His current area of expertise is enabling and consulting for WebSphere products, specializing in WebSphere Application Server, Portal, and Personalization. Before joining the Enablement team, Vishy was a member of the WebSphere development team. You can reach Vishy at vgadepal@us.ibm.com.
Comments (Undergoing maintenance)





