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:
- Enhancements to WebSphere Commerce Studio Version 5.4
- The development database must be a DB2(R) database
You must also locate the sample code included with this document. There are two files required:
- wsad_customer_profile.zip
- wcs_customer_profile.zip
Installing the sample in WebSphere Studio Application Developer
To install this sample into your development environment, you must do the following:
- Unzip the wsad_customer_profile.zip file into your workspace_dir directory,
where workspace_dir is the WebSphere Commerce workspace.
- 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:
- Start WebSphere Studio Application Studio.
-
From the File menu, select Import.
The Import window opens.
-
Select Existing Project into Workspace and click Next.
-
Click Browse to specify the project contents. Locate the tempDir\wcs.examples
project.
-
Click Finish.
-
Repeat step 1 but this time specify the tempDir\WCSExample-ejb
project.
-
To view the new code in your workspace, do the following:
-
From the Window menu, select Show view > Navigator.
The Navigator view opens.
-
In the Navigator view, highlight the following projects:
-
wcstores
-
wctools
-
WebSphereCommerceServer
-
Right-click and select Refresh.
Modifying the application configuration
To modify the application deployment descriptor, do the following:
-
Use the Navigator view. Expand the WebSphereCommerceServer project
and then expand the META_INF folder.
-
Double-click the application.xml file.
The Application Deployment Descriptor opens.
-
Select the Module tab.
-
Under Module, click Add.
The Add Module window opens.
-
Select the WCSExample-ejb.jar from the Projects found list and click
Finish.
-
Under Project Utility JARs, click Add.
The Add Utility Jar window opens.
-
Select wcs.examples from the Projects found list and in the URI
field, enter lib/wcsexamples.jar.
Click Finish.
-
The Repair Server Configuration window opens. Click OK to accept
it.
-
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:
-
Use the Navigator view and expand the wcstores Web project.
Next expand the Web Content and META_INF folders.
-
Right-click the manifest.mf file and select Open with > Text
Editor.
-
Add lib/wcsexamples.jar to the
class path.
-
Save your changes (Ctrl+S)
Next, you must modify the class path for the wctools Web project, as follows:
-
Use the Navigator view and expand the wcstores Web project.
Next expand the Web Content and META_INF folders.
-
Right-click the manifest.mf file and select Open with > Text
Editor.
-
Add lib/wcsexamples.jar to the
class path.
-
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:
-
Open the following file:
drive:\CommerceStudioEnhancements\Commerce\bin\setenv.bat
-
Modify any environment variables that are incorrectly specified.
Save the file.
Updating the database
To update the development database for the beverage preference sample,
do the following:
-
Open a DB2 command window.
-
Navigate to the following directory:
drive:\CommerceStudioEnhancements\Commerce\bin
-
From the preceding directory, issue the following command:
profileSampleCreatedb.db2 dbname dbuser dbpswd schema_owner
where
- dbname is the name of your development database
- dbuser is the name of the user for your development database
- dbpswd is the password for your database user
- schema_owner is the development database schema owner. Note this is
usually the upper-case of the database user.
- Check the profileSampleCreatedb.log under
drive:\CommerceStudioEnhancements\logs
to verify that no errors occurred during the database update.
- In the DB2 command window, ensure that you are still in the
drive:\CommerceStudioEnhancements\Commerce\bin directory.
- Issue the following command:
profileSamplePopulatedb.db2 dbname dbuser dbpswd schema_owner
where
- dbname is the name of your development database
- dbuser is the name of the user for your development database
- dbpswd is the password for your database user
- schema_owner is the development database schema owner. Note this is
usually the upper-case of the database user.
- Check the profileSamplePopulatedb.log under
drive:\CommerceStudioEnhancements\logs
to verify that no errors occurred during the database update.
Testing the new beverage preference sample
- Start WebSphere Studio Application Developer and switch to the
Servers perspective.
- Right-click the WebSphereCommerceServer test server and select Start
- Once the server has started, launch the WebSphere Commerce Accelerator.
http://localhost/webapp/wcs/tools/servlet/ToolsLogon?XMLFile=adminconsole.AdminConsoleLogon
- 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:
- Customizations to the Customer Profile Notebook
- Customizations to SegmentSaveControllerCmd
- Customizations to SegmentNotebookDataBean
- Customizations to SegmentConstraintListCmd
- Customizations to CheckUserInMemberGroupCmd
- A new beverage enterprise bean was created
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:
- resources.xml
- MySegmentNotebook.xml
- MySegmentNotebookB2B.xml
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:
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.