Download - Using IBM Rational Application Developer V7 to create · featured tooling for WebSphere Portal V6. In addition, WebSphere Portal

  • Using IBM Rational Application Developer V7 to create portlet services and enhanced portlets for

    IBM WebSphere Portal Server V6 Part of a series on portal and portlet development

    By Saurabh Agarwal

    Principal Software Engineer IBM Corporation

    Level: Introductory to Intermediate

    August 2007

    mailto:[email protected]

  • Contents Abstract...................................................................................................................... 3 Overview.................................................................................................................... 3

    Portlet services....................................................................................................... 3 Enhanced portlet development............................................................................... 4

    Portal tooling features in Rational Application Developer V7 ..................................... 4 Credential Vault service ......................................................................................... 5

    Using Credential Vault tooling in Rational Application Developer V7.................. 5 People Awareness feature ................................................................................... 11

    Using People Awareness tooling in Rational Application Developer V7 ........... 12 Business Process Portlet wizard .......................................................................... 14

    Creating process initiation portlets.................................................................... 15 Creating process task portlets .......................................................................... 23

    WebSphere Personalization feature..................................................................... 27 Personalizing content by using Rational Application Developer ....................... 28

    Other articles in this series....................................................................................... 37 Resources................................................................................................................ 38 About the author ...................................................................................................... 38

  • Abstract IBM® WebSphere® Portal Server Version 6 has many advanced features compared to its predecessor (V5), and IBM® Rational® Application Developer Version 7 is the first product in the IBM® Rational® Software Delivery Platform suite that has full-featured tooling for WebSphere Portal V6. In addition, WebSphere Portal V6 has enhanced portlet service, personalization, and business process features. This article guides developers through how to use Rational Application Developer V7 to build advanced portlets that can be readily deployed on WebSphere Portal server V6. It discusses various portlet services, Java™ Specification Request (JSR) 168 specifications, and how to generate these services automatically in portlets. This article also shows how to use the portal tooling in Rational Application Developer to define the rules and to personalize the portlets. Lastly, it shows how simple it is to develop business process portlets that integrate with the business process server provided with IBM WebSphere Portal Server V6. Java developers who intend to work on portlet development using Rational Application Developer V7 will learn how easy it is to write advance portlets using Rational Application Developer V7 tooling.

    Overview Rational Application Developer Version 7 is a premium product that is part of the IBM® Software Delivery Platform (SDP). Its many benefits cut across various dimensions that affect developers. It is a true integrated development environment (IDE), because it provides a single environment for designing, building, testing, and deploying, all from the same workbench.

    Portlet services Portlet services provide common functionality to the portlets. Each service has its own service-specific interface for the functionality that it offers. IBM WebSphere Portal V6 supports these services for both IBM portlets and standard portlets. IBM portlets and standard portlets have different portlet service interfaces. However, you can provide an implementation that can be used for both APIs. These services can be invoked only from within a portlet, and they cannot be invoked from themes or skins. These are among the common portlet services:

    • Credential Vault service • Property Broker service (also known as the Cooperative service) • Content Access service

  • Enhanced portlet development IBM WebSphere Portal V6 provides APIs to create portlets that can be customized for different user scenarios. These are the major features:

    • People Awareness: This feature enable users to collaborate with other users. This is provided by Person links on portlet JSP pages.

    • Business Process portlets: A business process is a set of activities that can be performed repeatedly to achieve business objective. Simply put, these are the business workflows.

    • Personalization: It enables you to generate the portlets that targets users based on their unique preferences. For example, a single portlet can be used to show local weather information to different users, based on their geographic location (which is provided in the preferences).

    IBM Rational Application Developer V7 provides an integrated development environment for portlet creation, coding, testing and deploying these portlets on IBM WebSphere Portal V6. The article guides you through developing these elements

    • Credential Vault service • Person links • Business Process portlets • Portlet personalization

    Portal tooling features in Rational Application Developer V7 Rational Application Developer V7 provides various wizards, dialogs, views and drag-and-drop operations. Let’s go through these capabilities in detail. First, we’ll create a Java Specification Request (JSR) 168 Java™Server Faces portlet project. We will use this project as our master project, and we will keep adding the specific functionalities to it. These are the steps to begin creating a JSR 168 Faces portlet project using Rational Application Developer V7:

    1. Open the Project Creation wizard using the menu option of File > New > Project.

    2. In the wizard, you can either type a name for a portlet project or select a portlet project from the Portals folder. (If the Portals folder is already there, check the Show all wizards check box).

    3. If asked to Enable Portal Development, click OK. 4. Enter SampleJSRFacesPortlets as the Project Name. 5. Select WebSphere Portal V6.0 as the runtime Target 6. Check the Add project to an EAR check box, so that we can deploy the

    portlets on the WebSphere Portal server. 7. We intend to create JSR 168 portlets, so select JSR 168 Portlet from the

    Portlet API pull-down menu. 8. We will create the portlets as we progress, so for now, uncheck the Create a

    portlet check box, and click Finish. This action creates a portlet project, which does not have any source file (either .java or .jsp) in it.

  • Credential Vault service A developer can implement Single Sign-On (SSO) feature in portal applications by using Credential Vaults provided by WebSphere Portal. In the context of WebSphere Portal, there are two SSO domains:

    • From the user interface (client, for instance) to the portal and other applications

    • From the portal to the backend database system Credential Vaults provide a way to retrieve users’ validated identities, which can be passed to the backend systems through the portlet. Using SSO, a user can provide credentials for the first time when logging into WebSphere Portal, and this information can be passed to other applications or systems as and when required. Thus, a user is not bothered to provide credentials each time, because the necessary data is fetched from backend. Here, WebSphere Portal server and the Web portal play the role of authentication proxy for other applications and systems. WebSphere Portal provides different vault segments where a user or an administrator can safely store the credentials used for authentication. These vault segments are either user-managed or administrator-managed. Portlets are allowed to create only user-managed vault slots. However, they can set and retrieve information from both kinds of slots. WebSphere Portal server provides two vaults in each of these vault segments:

    • Administrator-managed vault segments o System slot: The information stored in this slot is shared across all

    users and portlets. System authentication credentials are provided by administrators, and portlets can retrieve only this information from this slot (displayed in Edit and Configure portlet modes).

    o Administrative slot: Users can store authentication credentials for resources that are defined by an administrator (a mail server, for example). The information provided in this slot is private and visible only to the user (displayed in Edit and Configure portlet modes).

    • User-managed vault segments o Shared user slot: Information provided in this slot is shared among a

    user’s portlets (displayed in Edit portlet mode). o Portlet private slot: User credentials provided here are not shared

    among the portlets (displayed in Edit portlet mode).

    Using Credential Vault tooling in Rational Application Developer V7 Now, let’s see how Rational Application Developer tooling helps in creating these vaults.

    Creating Credential Vaults Let’s create SampleCVPortlet in the already-created SampleJSRFacesPortlets, using the File > New > Others > Portlet menus.

  • 1. In the New Portlet wizard, make sure that the project is SampleJSRFacesPortlets, and enter the portlet name as: SampleCVPortlet.

    2. Make sure that the portlet type is Faces portlet. Click Next twice to reach the Advanced Settings page of the New Portlet wizard.

    3. On this page, select Add credential vault handling check box under Single Sign-on group, and click the Use administrative credential vault slot radio button.

    4. In the slot name text box, provide a meaningful name. For our case, let’s use DominoServerAccount, and then click Finish.

    5. The workbench automatically creates Java™Server Pages (JSP) source files for three different portlet modes:

    • For config mode: and SampleCVPortletConfig.jsp

    • For edit mode: and SampleCVPortletEdit.jsp

    • For view mode: and SampleCVPortletView.jsp and will open SampleCVPortletView.jsp in the Page Designer.

    6. The Rational Application Developer V7 workbench: A. Modifies the portlet deployment descriptor, (WebContent/WEB-

    INF/portlet.xml, and adds initialization parameters to it, as this code snippet shows:

    AdminSlotReferences DominoServerAccount

    Figure 1: Portlet Initialization parameters in PDD view

    B. Places the portlet-cv.jar file in the Web application’s class path.

  • 7. These Java source files are the Java™Beans elements, which have all the action methods defined:

    Figure 2: Portlet project in Project Explorer

    8. Also, the Page Data view of the workbench reflects the action controls for

    config mode and edit mode, respectively, that Figures 3 and 4 show.

  • Figure 3: Page bean for configuration mode

    Figure 4: Page bean for edit mode

    9. Similarly, if any other credential vault slot is selected, the workbench generates Java and JSP source files automatically and modifies the portlet deployment descriptor to make the developer’s job easier.

    10. Let’s run this portlet on WebSphere Portal V6 using drop-down menu Run As… > Run on Server. Our portlet is shown on the workbench’s internal

  • browser in the View mode (SampleCVPortletView.jsp with the default content).

    Figure 5: SampleCVPortlet when run on server

    11. Now, let’s go to the Administration (admin) console of WebSphere Portal

    V6 to create the admin slot. To do this, click the Administration link provided at the bottom menu.

    12. From the left-hand menu bar, click the Credential Vault link, and then click Add a vault slot.

    Figure 6: Credential Vault in the portal admin console

    13. Provide the necessary details on the input form, and then click OK.

  • Figure 7: Credential Vault in the WebSphere Portal admin console

    14. Now, hover your mouse cursor over the top-right corner of the portlet so that

    you can see the Portlet menu icon, which you can click to display the menu. Select the Configure option to switch to Config mode.

    Figure 8: SampleCVPortlet on the portal server

    15. On the Configuration page. provide the actual slot name, and click Save:

  • Figure 9: SampleCVPortlet in config mode

    16. Now, so you can store the user credentials in the administrative vault slot

    (created previously in Steps 13–15), click the Personalize option from Portlet menu, to open the JSP file in Edit mode. In this mode, the entry is displayed in the table without a user name and password.

    Figure 10: SampleCVPortlet in edit mode

    People Awareness feature The People Awareness feature of WebSphere Portal V6 allows developers to use WebSphere collaboration features in portlets. This is achieved by the use of Person links in portlet JSPs. Tip If IBM® Lotus® Sametime® server is configured with the WebSphere Portal server, then Person links can also be used to indicate a person’s status (Active, Away, Offline, or Do Not Disturb). Users can click the Person link to display various actions in a menu that can be used to collaborate with the person represented by the link. These actions may include Chat, Send e-mail, and so on. The Person link is provided by the Person JSP tag. It provides contextual collaboration with the person named. It also generates the HTML responsible for generating the drop-down Person action menu on the Person links.

  • Using People Awareness tooling in Rational Application Developer V7 Rational Application Developer V7 provides the Person tag in the Palette view under the Portlet drawer. You can drag and drop this Person tag from the palette to the portlet JSP and use the Properties view to customize it.

    Creating Person tags Now we will create a new portlet, SamplePeopleAwareness, in the already-created SampleJSRFacesPortlets project.

    1. Invoke the New Portlet creation wizard from drop-down menu (right-click) of SampleJSRFacesPortlets.

    2. In the New Portlet wizard, make sure that the project is SampleJSRFacesPortlets, and then enter the portlet name as SamplePeopleAwareness.

    3. Make sure that the portlet type is Faces portlet. Click Next and then Finish. 4. This action opens the portlet view JSP (SamplePeopleAwarenessView.jsp) in

    the design pane of the Page Designer. 5. Replace the Place content here text with: Hello, this is a sample

    collaborative services page. 6. From the Portlet drawer of the Palette view, select the Person link and drag

    it to just after the Hello… text.

    Figure 11: Drag-and-drop the Person link

    7. The Rational Application Developer workbench automatically places the jsf-

    portlettags.jar tag library in the WEB-INF/lib folder of the project and adds following tag lib URL to the JSP page:

    8. It also places the tag in the SamplePeopleAwarenessView.jsp file.

    9. A Person tag has following attributes: • Value: The unique ID • Value type: The type of value specified for value. It can be any of


  • o LDAPDN: The default value, used for an LDAP Distinguished Name

    o EMAIL: To specify the e-mail ID of the person o MEMBERDN: Member distinguished name, from WebSphere

    Member Manager o WMMID: The unique WebSphere Member Manager ID

    • Display name: The string that will be displayed on the JSP page 10. Now, let’s customize the Person tag. Open the Properties view of

    workbench by using Windows > Show View. 11. Select the Person link icon ( ), and the Properties view will show the

    attributes for the Person tag.

    Figure 12: JSP Properties view

    12. For this example, let’s select the value type as email, and provide the e-mail

    address of the person in the Value field. The display name attribute will hold the string that will be displayed on the JSP. Our string in the Design pane of the JSP file looks what Figure 13 shows: Hello , this is a sample collaborative services page.

    Figure 13: JSP Design view

    13. Now save the JSP file, and run this portlet using the Run As… > Run on

    Server menu option from the drop-down menu of the portlet project in the Project Explorer view.

    14. The workbench opens the internal Web browser to display the portlet (see Figure 14).

  • Figure 14: People Awareness portlet running on the server

    15. Notice that the name is shown as a link, and hovering your mouse cursor will

    activate a pull-down menu arrow icon ( ). Click this icon to display the Action menu (Figure 15).

    Figure 15: People Awareness portlet on the server

    16. In this Action menu, we are presented with a Send E-mail option. Clicking on

    this action opens the default e-mail client software and places the e-mail ID of the person ([email protected], in our case) in the To field.

    Business Process Portlet wizard A business process is a step-by-step procedure that is performed by several people in an organization to achieve a particular business goal. It is a set of linked activities

    mailto:[email protected]

  • that take an input and transform it to create an output. The process is defined so that it adds value to the input. Thus, the output generated is effective and useful. For example, a business process could be an employee expense reimbursement system. This process might involve the following tasks, performed by different people:

    1. An employee initiates an expense reimbursement request. 2. The employee’s manager approves the request and forwards it to the

    Accounts Payable department (if rejected, they send it back to the employee for amendments)

    3. A member of the Accounts Payable department verifies the nature of the claim, required receipts, and necessary business approvals. After verifying these, that person forwards the reimbursement request to the appropriate person in the Accounting department and authorizes release (payment) of the requested amount. (If the request is rejected, the employee can amend it on the basis of rejection comments)

    4. On receipt of the request, the Accounting department pays the employee. Business process portlets interact with the business processing code to initiate the process and then to request or process the task and the supported modules. WebSphere Portal V6 does not require that WebSphere Business Integration Server Foundation run business process. However, WebSphere Integration Developer should be used to develop business processes for WebSphere Portal server V6. Rational Application Developer V7 provides tooling to create and deploy a business process portlet. By providing portlet project and portlet creation wizards, Rational Application Developer V7 gives you tools to create business process portlets both for task-initiation and task-processing requests.

    Creating process initiation portlets Before starting to create business process portlets, the business process should be designed, using WebSphere Integration Developer. It provides a BPEL process editor to design the business process (including data flow and its control, input and output message syntax, and the semantics of activities contained in the process). The generated artifacts of this business process (exported as Java™ Archive, or JAR files) are used in creation of a business process portlet. See Resources for a link to the WebSphere Integration Developer for more information. Also, the WebSphere Portal process server should be configured with Business Process Container, Human Task Manager so that a business process portlet can be deployed on it. For more details on this, check the WebSphere Portal Server Information Center (see Resources). Let’s create a new portlet called SampleBPPortlet in the already created SampleJSRFacesPortlets project.

  • 1. For creating the SampleBPPortlet portlet, invoke the Portlet Creation wizard, from drop-down menu (right-click) of SampleJSRFacesPortlets.

    2. In the New Portlet wizard, make sure that the project is SampleJSRFacesPortlets, and enter portlet name as SampleBPPortlets.

    3. Make sure that the portlet type is Faces portlet. Click Next, and then click Next again until you reach the Advanced Settings page.

    4. Check the Enable business process integration check box in the Business Process group box, and then select the Add Process Initiation radio button. This enables the Template name for the process template that’s defined in the Business Process Execution language (BPEL, using WebSphere Integration Developer).

    5. Click Finish. This creates SampleBPPortlets and opens SampleBPPortletsView.jsp in Page Designer editor.

    6. The workbench provides: • The portlet-bp.jar file in the Web application’s class path. • A Business Process EJB reference (see the code snippet that follows),

    which is required by process initiation helper) in the Web deployment descriptor deployed on the target WebSphere Portal server V6.

    This reference should be mapped to the JNDI name of the EJB that’s

    ejb/BusinessFlowManagerHome Session

  • Figure 16: ReimbursementRequestProcess WSDL

    . • GenEmployeeReimbursementProcess.wsdl: Defines the input for the

    processing and output as the result of this processing (for example, amount disbursement into employee bank account). These WSDL files are imported in the Web Content/wsdl folder of our project. (See Figure 17.)

    Figure 17: GenEmpoyeeReimbursementProcess WSDL

    9. To initiate a business process, open SampleBPPortletsView.jsp in Page Designer.

  • 10. From the Page Data view’s drop-down menu, use New > Other > Business Process Message to launch the Business Process Creation wizard (or right-click the Services node of the Page Data view, and use New > Business Process Message to launch this wizard).

    Figure 19: Business Process Creation wizard

    11. On the Message Schema File page, select the intended action (in our case,

    it would be initiate a business process) and browse for InitiateEmployeeReimbursementProcess.wsdl, and click Next.

    12. The Message Selection page displays the port types defined in the WSDL file, their operations, and the associated input and output messages. You can select: • A message • Two messages defined for the same operation (input and output). With

    that option, two Page Data nodes are created. For our sample, let’s select the ReimbursementRequest as the input message, and then click Finish.

  • Figure 20: Input and output message selection

    13. This action automatically generates the necessary code in the page bean.

    The code in Listing 2 shows the file that is modified automatically (this can be edited by right-clicking anywhere on the JSP in the Design view and selecting Edit Page Code).

  • Listing 2. code

    public class SampleBPPortletsView extends PageCodeBase { private Object reimbursementRequestOperationRequest; /** * * messageSchema=/SampleJSRFacesPortlets/ * WebContent/wsdl/InitiateEmployeeReimbursementProcess.wsdl# * {} * ReimbursementRequestOperationRequest */ public Object getReimbursementRequestOperationRequest() { if (reimbursementRequestOperationRequest == null) {

    reimbursementRequestOperationRequest = getSessionScope(). get(ProcessInitiationHel


    } return reimbursementRequestOperationRequest; } /** */ public String initiateProcess() {

    ProcessInitiationHelper helper = (ProcessInitiationHelper)getSessionScope().

    i i i

  • The Page Data view has the initiateProcess() action node for the Page Bean node, and the Services node shows the request:

    Figure 21: Page Data view for the page bean

    14. To generate the input request form, drag the reimbursementRequestOperationRequest node and drop it on the JSP in the Design pane.

  • Figure 22: Drag the service onto the JSP

    15. This opens the Configure Data Controls wizard (Figure 23), where you

    define the type of controls. For our sample, we want to create a new record, so we will select Creating a new record, and then click Finish.

    Drag and drop

  • Figure 23: Configure Data Controls wizard

    16. This generates the input form in the JSP with a Submit button. 17. To bind the action, we need to drag initiateProcess() node from the Page

    Data view onto the Submit button. 18. This completes our process request initiation portlet.

    Creating process task portlets Now, let’s create a task for handling the portlet JSP.

    1. For this purpose, create a new portlet JSP using File > New > Other > Web > Web Page, and name it SampleBPTaskProcess.jsp.

    2. From the Page Data view, right-click Services and use New > Business Process Message to launch the Business Process wizard.

    3. Select the Handle a task in business process radio button, provide the path of the WSDL file (in this case

  • WebContent\wsdl\GenEmployeeReimbursementProcess.wsdl) and click Next.

    Figure 24: Business Process initiation wizard

    4. Select input and output messages for both reimburseAmountRequest and

    reimburseAmountResponse nodes, and click Finish. 5. The Page Data view shows nodes for various helper methods required to

    complete the process, and the Services node shows the request and response defined in the WSDL file (see Figure 24).

  • Figure 25: Page Data view for the process task page bean

    6. The file has all of the necessary control

    methods, which are generated automatically by the wizard:

  • Figure 26: Generated methods, in page code

    7. Now, drag and drop the reimburseAmountResponse Service node from the Page Data view onto the JSP to generate the form. This opens the Configure Data Controls wizard to configure the control type.

    8. This action also generates the Faces command buttons, and the page bean actions can be bound to these buttons by dragging them onto these buttons.

    Figure 27: Drag-and-drop controls and bind to button

    Drag and Drop

  • This completes the creation of the business process portlet. These portlets now can be deployed directly onto the WebSphere Portal server from within Rational Application Developer V7.

    WebSphere Personalization feature The IBM WebSphere Personalization feature gives you advanced personalization capabilities. Administration functionality provides a mechanism to specify the portlet location and availability on a specific page; whereas, personalization services provide personalization using rule engines, user profiles, and your preference settings. Personalization can be of three types:

    • Filters: Content is displayed based on predefined groups. For example, a portal site displays finance-related information if the visitor is from the Finance or Accounting department.

    • Rules engines: The administrator defines a set of business rules that ascertain the content to be displayed for visits that match a certain profile type. For instance, a mobile telephony service provider might want to display a new range of services or products to all subscribers from a particular geography whose last-month billing was more than a certain amount.

    • Collaborative filtering: A site asks a visitor to rate a particular selection of products, and these ratings are compared with the ratings provided by other visitors. This will enable the administrator to define the content that is shown to the users, such as a list of movie DVDs that is based on similar orders from other buyers.

    Using rule-based system to define complex filtering can be taken as a guideline when deciding for the personalization.

    Personalized content can be defined through various applications. Personalization detects the content definition from these applications automatically and generates the content. Rational Application Developer provides personalization wizards to define database or LDAP content types. User resources, content resources. and Content Spots are required to create a personalized content.

    • Content and user resources: Java classes and resource files (.hrf or .xml) that access the user data or Web content are the content resources. The content is dynamically generated and displayed in a particular format, using a JSP or a servlet.

    • Content Spot: A Content Spot is a placeholder for a content rule on a Web page. It is essentially a Java wrapper class (a Java bean) that is placed on the Web page, and it invokes the rule to get the personalized content for the personalized Web site.

  • Personalizing content by using Rational Application Developer Rational Application Developer provides wizards to create Content Spots, as well as user and content resources. You can use them to generate personalization resources in the portlets.

    1. Create SamplePznPortlets in the SampleJSRFacesPortlet portlet project already created.

    2. From File > New > Other, select the Content or User Resource wizard and click Next.

    Figure 28: Content or User Resource wizard

    3. In the Specify Protocol and Data Model screen (Figure 27), choose the protocol (SQL or LDAP) and click Next.

  • Figure 29: Specify Protocol and Data Model screen

    4. On Select Connection page, choose to create a new connection, and then

    click Next to land on the Connection Parameters page. 5. On this page, we can define the database details, including the Java™

    Database Connectivity (JDBC) driver, Connection URL, and User credentials. 6. This examples uses the Cloudscape database provided by WebSphere Portal

    server. To create a sample database, follow these steps: A. Double-click the cview.bat file from

    /AppServer/cloudscape/bin/embedded to launch the Cloudscape database.

    B. Create a new database named sample by using the File > New Database menu.

    C. Create Employee and Dept tables using the drop-down menu on the Table node under the sample database.

  • Figure 30: New table

    D. Create two columns in the Dept table (see Figure30).

    Figure 31: Columns for Dept

    E. Create three columns in the Employee table (Figure 31).

  • Figure 32: Columns for Employee

    7. Provide the details of this database and click Next to reach the Construct a

    Personalization Resource page. 8. Select the DEPT and EMPLOYEE under Available Tables.

  • Figure 33: Construct a Personalization Resource dialog

    9. Select both of these tables and click the single right-arrow button to add them to the Selected Tables list. Then, select the Employee table and click Primary Table, and select Columns tab.

    10. In the Columns tab, click the double right-arrow button to select both tables in the right pane.

    11. Expand the DEPT table, select DEPT_ID, and declare it as primary key by clicking the Primary Key button. Similarly, for EMPLOYEE table, declare EMPLOYEE_SERIAL as primary key.

  • 12. (Optional) Click the Joins tab to define a connection between the DEPT.DEPT_ID and EMPLOYEE.EMPLOYEE_DEPT columns.

    Figure 34: Personalization resource dialog box, Joins tab

    13. Now select the Deployment tab to specify the DataSource name. For this

    example, name it as SamplePzn, and then click Next. 14. On the Resource Generation Options page, provide the package name as

    sample.pzn and click Finish. 15. The workbench now completes these tasks:

    A. Generates a resource file called Employee.hrf under WEB-INF/pzn-resourceCollections/sample/pzn (Figure 34). If the personalization resource is to be modified at a later stage, this file can be double-clicked to open the Create Personalization Resource wizard.

    Figure 35: Employee.hrf

  • B. Generates personalization classes under the src/sample/pzn folder (Figure 35), representing the table columns.

    Figure 36: Generated classes

    16. Now, to create a Content Spot, launch the wizard using File > New > Other… and, on the Select a wizard page, select Content Spot from Portal > Personalization and click Next.

    17. Provide all of the input values, and then click Finish.

  • Figure 37: New Content Spot

    18. This generates the file in the src/sample/pzn/cspot folder

    (Figure 37).

    Figure 38: Content Spot bean

    19. The source code of generated class looks like the code in Listing 3.

  • Listing 3. Source code for the generated class

    public class ContentSpot extends RuleTrigger { public ContentSpot() { super(); } public String getDisplayName() { return "ContentSpot"; } public Object[] getRuleContent() throws Throwable { Object[] objArray = super.getRuleResults(); if ((objArray != null) && (objArray.length > 0)) { Object[] tempArray = new Object[objArray.length]; for (int i = 0; i < objArray.length; i++) tempArray[i] = (Object)objArray[i]; return tempArray; } return new Object[0]; } public Object getRuleContent(int which) throws ArrayIndexOutOfBoundsException, Throwable { return (Object)super.getRuleResults(which); } }

    This Content Spot must be registered with the Personalization Engine by creating the Content Spot reference.

    20. Drag Content Spot class, onto the JSP to create the JSP usebean reference.

  • Figure 39: Drag the Content Spot bean onto the JSP

    Drag and Drop Drag and DropDrag and drop

    21. Now this JSP file can be modified to pass the request object to the

    Personalization Engine.

    Other articles in this series Check the One-stop guide to portal and portlet application development using Rational Application Developer V7 and WebSphere Portal V6 for summaries of the nine other articles in this series and links to download each of them in PDF format. Topics covered include the predevelopment resources, portlet tooling features, portal design tools, and the testing, deploying, and debugging capabilities of Rational Application Developer.

  • Resources Learn

    • Get information on IBM Rational Application Developer and how to use it: o What's new in IBM Rational Application Developer V7.0 o IBM Rational Application Developer Version 7.0 Information Center o Rational Application Developer page on IBM® developerWorks®

    • For WebSphere Portal: o Visit the IBM WebSphere Portal Version 6.0 Information Center. o Read Developing portal and portlet applications o Find out What’s new in WebSphere Portal Version 6. This

    developerWorks article by Stefan Hepper, Stefan Liesche, Gregory Melahn, and Thomas Stober (July 2006) describes the highlights in IBM® WebSphere® Portal Version 6.0.

    • For information on WebSphere Integration Developer, visit IBM WebSphere Integration Developer 6.0 Information Center.


    • Participate in the Rational Development Tools forums, which include sections for Rational Software Architect, Data Architect, Software Modeler, Systems Developer, Application Developer and Web Developers. Discuss technical aspects, ask questions, share tips, talk about solutions to problems. To participate by e-mail, subscribe by sending a note to mailto:[email protected] Subscribers may post by sending e-mail to [email protected]

    • Join the WebSphere Portal forum technical discussions.

    Get software • Get the evaluation version of Rational Application Developer. • Get WebSphere evaluation versions from the WebSphere downloads page.

    About the author Saurabh Agarwal is the project lead for the Portal Tooling component in Rational Application Developer in the Lotus group at IBM India Software Labs in Delhi, India. He has more than seven years of experience in Java and Web development, with the most recent years of that experience at IBM.[email protected]:[email protected]:[email protected]://

    AbstractOverviewPortlet servicesEnhanced portlet development

    Portal tooling features in Rational Application Developer V7Credential Vault serviceUsing Credential Vault tooling in Rational Application Developer V7Creating Credential Vaults

    People Awareness featureUsing People Awareness tooling in Rational Application Developer V7Creating Person tags

    Business Process Portlet wizardCreating process initiation portletsCreating process task portlets

    WebSphere Personalization featurePersonalizing content by using Rational Application Developer

    Other articles in this seriesResourcesAbout the author