Finish coding the portlet JSP

 

+
Search Tips   |   Advanced Search

 

Ensure you have properly followed the steps in Create the Personalization user resource classes and content spot

  1. From the RAD Project Explorer, open...

    PersOffers/WebContent/pers_offers/jsp/html/Pers_OffersPortletView.jsp

  2. Drag and drop the pers_offers.Pzn_offersSpot.class file from...

    PersOffers/WebContent/WEB-INF/classes/pers_offers

    ...onto the top of the jsp. This is one of the classes you generated in the content resource wizard.

  3. In the Properties window, type offersSpot in the Id field.

  4. Drag and drop the pers_offers.Pers_Offers_UserSpot.class file from...

    PersOffers/WebContent/WEB-INF/classes/pers_offers

    ...onto the top of the jsp.

  5. In the Id field, type userSpot.

  6. Switch to source mode in the jsp editor.

  7. Replace the existing text with the following sample. The setRequest calls pass the user context to personalization:

    <%@ page session="false" 
        contentType="text.html" 
        import="java.util.*, pers_offers.*"%>
    
    <%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portletAPI" %>
    
    <portletAPI:init/>
    
    <jsp:useBean class="pers_offers.Pzn_offersSpot" id="offersSpot"></jsp:useBean>
    
    <jsp:useBean class="pers_offers.Per_Offers_UserSpot" id="userSpot"></jsp:useBean>
    
    <%
    
    offersSpot.setRequest(request);
    
    userSpot.setRequest(request);
    
    %>
    

  8. Save the file and check for syntax errors.

  9. Insert the following code at the bottom of the jsp:
    <DIV style="margin: 6px">
    
     
    
    <H3 style="margin-bottom: 3px">Welcome to Personalized Offers!</H3></DIV>
    
    <BR>
    
    Here is a personalized offer:<BR>
    
    <%=offersSpot.getRuleContent()[0].getTitle() %>
    
    <br>
    
    <%=offersSpot.getRuleContent()[0].getDetails() %>

  10. Save and close the jsp.

You have completed the basic coding of the personalized portlet. We can now export the WAR file from Rational Application Developer and install the portlet in WebSphere Portal.