|
|
Deploying the New Example Portal
In this chapter, you will log in as different users to see the portal in action. Then you will enhance the exampleportal login to increment users' AcmePoints automatically when users log in to the Web site.
This topic includes the following sections:
Viewing the New Example Portal
You have set up everything you need to view the Acme Web site (exampleportal). Now you will view the Web site on the WebLogic Server, both as a frequent visitor and an infrequent visitor.
To view the frequent visitor personalization message, you will log in as democustomer. To view the infrequent visitor hints, you will not log into the portal. The portal will then read the default AcmePoints value of zero.
Logging in as a Frequent Visitor
http://<machine-name>:<port>/exampleportal
Note: If you don't know your machine name, use your network or machine login name. Windows users: Do not use the Start menu exampleportal URL. Type the URL in your browser.
This is the user you created with five AcmePoints. When you log in, you will see the frequent visitor messages in the "tutorial" portlet, because democustomer is classified as a frequent visitor.
Logging in as an Infrequent Visitor
Because you did not log in, and the default AcmePoints value is zero, you are classified as an infrequent visitor and the "tutorial" portlet displays hints.
Enhancing the Example Portal Login
You can add code to a login page to have the page increment each user's AcmePoints each time they visit the exampleportal. To enhance the login, insert code similar to the example below into the login page. The code increments the logged in users' AcmePoints by 1 each time they log in.
<%-- Load the user's profile into scope. --%>
<um:getProfile scope="session" profileKey="<%=username%>" />
<%-- Get current AcmePoints --%>
<um:getProperty id="points" propertySet="exampleportal" propertyName="AcmePoints"/>
<%
// increment AcmePoints
long newTot = ((Long)points).longValue() + 1;
Long newTotal = new Long(newTot);
%>
<%-- Set incremented AcmePoints --%>
<um:setProperty propertySet="exampleportal" propertyName="AcmePoints" value="<%=newTotal%>"/>
Follow these steps to add this code:
<%-- Begin: Insert Personalization tour code here --%>
<%-- End: Insert Personalization tour code here --%>
Note: You can also add the following line of code at the end of the example code as a troubleshooting tool. The code prints a comment in the console window when the code runs successfully:
<% System.out.println("adding points for user: " + username); %>
Note: You can also see the new AcmePoints value for the "acme" user by looking at the user's profile in the Administration Tools. For more information, see Editing User Properties in Working with User Profiles.
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|