Customization Scenario Sample


Enhancements to IBM(R) WebSphere(R) Commerce Studio

Version 5.4


Example of customizing WebSphere Commerce Accelerator

Introduction

This sample uses WebSphere Studio Application Developer to demonstrate how a new attribute can be added to the customer profile component of the WebSphere Commerce Accelerator. The new attribute is "beverage preference". This attribute is stored in a new table called "beverage" and a new enterprise bean is used to access this attribute. Once installed, marketing managers can use WebSphere Commerce Accelerator to create and modify customer profiles that include the "beverage preference" attribute. A new panel called "Preferred beverage" will be added under the "Miscellaneous" tab in the "Customer Profiles" notebook.

There are two parts to adding a new attribute to the customer profiles component. The customer profile tool must be extended to allow the marketing manager to add the new attribute. This means that the Customer Profile Notebook in the WebSphere Commerce Accelerator must be modified to have a new panel where the details of the new attribute can be specified. The second part to adding a new attribute is to customize the run-time evaluation of customer profiles so that the new attribute is recognized.

Prerequisites

Before working through this sample, you must have the following installed:

You must also locate the sample code included with this document. There are two files required:

Installing the sample in WebSphere Studio Application Developer

To install this sample into your development environment, you must do the following:

  1. Unzip the wsad_customer_profile.zip file into your workspace_dir directory, where workspace_dir is the WebSphere Commerce workspace.
  2. Unzip the wcs_customer_profile.zip file into the following directory:
    drive:\CommerceStudioEnhancements\Commerce

Importing the sample code

Next, you must import the sample Java(TM) code into WebSphere Studio Application Developer, as follows:
  1. Start WebSphere Studio Application Studio.
  2. From the File menu, select Import.

  3. The Import window opens.
    1. Select Existing Project into Workspace and click Next.
    2. Click Browse to specify the project contents.  Locate the tempDir\wcs.examples project.
    3. Click Finish.
  4. Repeat step 1 but this time specify the  tempDir\WCSExample-ejb project.
  5. To view the new code in your workspace, do the following:
    1. From the Window menu, select Show view > Navigator.

    2. The Navigator view opens.
    3. In the Navigator view, highlight the following projects:
      • wcstores
      • wctools
      • WebSphereCommerceServer
    4. Right-click and select Refresh.

Modifying the application configuration

To modify the application deployment descriptor, do the following:
  1. Use the Navigator view. Expand the WebSphereCommerceServer project and then expand the META_INF folder.
  2. Double-click the application.xml file.

  3. The Application Deployment Descriptor opens.
  4. Select the Module tab.
  5. Under Module, click Add.

  6. The Add Module window opens.
  7. Select the WCSExample-ejb.jar from the Projects found list and click Finish.
  8. Under Project Utility JARs, click Add.

  9. The Add Utility Jar window opens.
  10. Select wcs.examples from the Projects found list and in the URI field, enter lib/wcsexamples.jar. Click Finish.
  11. The Repair Server Configuration window opens. Click OK to accept it.
  12. Save the changes you made to the application.xml file (Ctrl+S).
Next, you must modify the class path for the wcstores Web project, as follows:
  1. Use the Navigator view and expand the wcstores Web project.   Next expand the Web Content and META_INF folders.
  2. Right-click the manifest.mf file and select Open with > Text Editor.
  3. Add lib/wcsexamples.jar to the class path.
  4. Save your changes (Ctrl+S)
Next, you must modify the class path for the wctools Web project, as follows:
  1. Use the Navigator view and expand the wcstores Web project.   Next expand the Web Content and META_INF folders.
  2. Right-click the manifest.mf file and select Open with > Text Editor.
  3. Add lib/wcsexamples.jar to the class path.
  4. Save your changes (Ctrl+S).
Next, you must ensure that all of the environment variables are specified correctly in the setenv.bat file.   To perform this verification, do the following:
  1. Open the following file:
    drive:\CommerceStudioEnhancements\Commerce\bin\setenv.bat
  2. Modify any environment variables that are incorrectly specified.

  3. Save the file.

Updating the database

To update the development database for the beverage preference sample, do the following:
  1. Open a DB2 command window.
  2. Navigate to the following directory:
    drive:\CommerceStudioEnhancements\Commerce\bin
  3. From the preceding directory, issue the following command:
    profileSampleCreatedb.db2 dbname dbuser dbpswd schema_owner
    where
    1. dbname is the name of your development database
    2. dbuser is the name of the user for your development database
    3. dbpswd is the password for your database user
    4. schema_owner is the development database schema owner. Note this is usually the upper-case of the database user.

  4. Check the profileSampleCreatedb.log under
    drive:\CommerceStudioEnhancements\logs
    to verify that no errors occurred during the database update.
  5. In the DB2 command window, ensure that you are still in the drive:\CommerceStudioEnhancements\Commerce\bin directory.
  6. Issue the following command:
    profileSamplePopulatedb.db2 dbname dbuser dbpswd schema_owner
    where
    1. dbname is the name of your development database
    2. dbuser is the name of the user for your development database
    3. dbpswd is the password for your database user
    4. schema_owner is the development database schema owner. Note this is usually the upper-case of the database user.
  7. Check the profileSamplePopulatedb.log under
    drive:\CommerceStudioEnhancements\logs
    to verify that no errors occurred during the database update.

Testing the new beverage preference sample

  1. Start WebSphere Studio Application Developer and switch to the Servers perspective.
  2. Right-click the WebSphereCommerceServer test server and select Start
  3. Once the server has started, launch the WebSphere Commerce Accelerator.
    http://localhost/webapp/wcs/tools/servlet/ToolsLogon?XMLFile=adminconsole.AdminConsoleLogon
  4. From the Marketing menu, you will see a new panel called "Preferred beverage" is added under the "Miscellaneous" tab in the "Customer Profiles" notebook.

Understanding the customizations to the Customer Profile Notebook

This beverage preference sample includes the following customizations:

Each of these customizations are described in more detail in the following sections.

Customizations to the Customer Profile Notebook

The Customer Profile Notebook in the WebSphere Commerce Accelerator is modified by this sample to allow the new "beverage preference" attribute to be specified by the marketing manager. A new panel called "Beverage preference" is added under the "Miscellaneous" tab on the left side of the Customer Profile Notebook. This new panel is implemented as a JSP file. The name of the JSP file is BeveragePanel.jsp. During the installation of this sample, the JSP file is registered in the view registry and appropriate access control is assigned to the new view. For more details on this registration, refer to the schema/xml/profileSample.xml file.

Once the new view is registered, the XML document that describes the Customer Profile Notebook must be modified to include the new panel. The installation of this sample placed three new XML documents in the xml/tools/segmentation directory in the WebSphere Commerce root directory. These new files are:

Compare these documents to resources.GA.xml, SegmentNotebook.xml, and SegmentNotebookB2B.xml which can be found in the same directory. You will see how the new panel was added to the Customer Profiles Notebook. (Note: The original resources.xml is renamed to resources.GA.xml.)

The installation utility also modified the properties/com/ibm/commerce/tools/segmentation/Resources.properties file in the installed enterprise application to include the segmentNotebookBeveragePanel resource.

Customizations to SegmentSaveControllerCmd

SegmentSaveControllerCmd is the name of the controller command that saves a customer profile. This controller command was modified by extending the original implementation class and registering the new implementation class in the command registry. Refer to the java/com/mycompany/tools/segmentation/MySegmentSaveControllerCmdImpl.java file for details on how the controller command was customized. Refer to the schema/xml/profileSample.xml file for details on how the new implementation was registered in the command registry.

Customizations to SegmentNotebookDataBean

SegmentNotebookDataBean is the name of the data bean that is used to describe a customer profile. This data bean was modified by extending the original data bean. Refer to the java/com/mycompany/tools/segmentation/MySegmentNotebookDataBean file for details on how this data bean was customized.

Customizations to SegmentConstraintListCmd

SegmentConstraintListCmd is a task command that provides the list of implicit constraints that make up a customer profile. This list is in HTML format and is displayed on the Customer Profile Summary page. The task command was modified be extending the original implementation class and registering the new implementation class in the command registry. Refer to the java/com/mycompany/tools/segmentation/MySegmentConstraintListCmdImpl.java file for details on how this task command was customized. Refer to the schema/xml/profilsSample.xml file for details on how the new implementation was registered in the command registry.

Customizations to CheckUserInMemberGroupCmd

CheckUserInMemberGroupCmd is a task command that checks to see if a user is in a member group. It is responsible for evaluating the implicit criteria for the member group to see if the user belongs to the member group. This task command was modified by extending the original implementation class and registering the new implementation class in the command registry. Refer to the java/com/mycompany/membergroup/commands/MyCheckUserInMemberGroupCmdImpl.java file for details on how this task command was customized. Refer to schema/xml/profilsSample.xml file for details on how the new implementation was registered in the command registry.

The new Beverage enterprise bean

The new "beverage preference" attribute is to be stored in a table called "BEVERAGE". For details on how this table is defined refer to the schema/db2/profileSample.schema.sql file. This table is accessed by a new enterprise bean called Beverage. In order to assign beverage preferences to users, you will need to insert new rows into this table.
 

--------------------------------------------------------------------------------

Trademarks and Service Marks

The following are trademarks or registered trademarks of IBM Corporation in the United States and other countries:
DB2 IBM WebSphere

Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.

Other company, product, or service names may be trademarks or service marks of others.

**************************************************************************

** © COPYRIGHT INTERNATIONAL BUSINESS MACHINES CORPORATION 2002

** ALL RIGHTS RESERVED.

**************************************************************************
Note to US Government Users -- Documentation related to restricted rights -- Use, duplication, or disclosure is subject to restriction set forth in GSA ADP Schedule Contract with IBM Corp.
End of document.