Feature Pack 7 or later

Load your widget into the database by using Data Load utility

In this lesson, you use the Data Load utility to register your new widget and have a store subscribe to your widget.

To use a widget to compose a page layout for a store, you must load the relationship between the widget and the store. A store must subscribe to a widget for that widget to be available for users to include the widget in a layout. You can use the generated CSV files and Data Load utility configuration files to help you load your widget information into the database.

For more information about loading widget information with the Data Load utility, see Registering a Commerce Composer widget.

For more information about the Data Load utility, see Overview of the Data Load utility.

Procedure

  1. In a File Manager, go to the DataLoad\widget directory within your new project directory.
    If you created your new project directory at the top level in your workspace, the path to this directory can be workspace_dir\NewWidgetProject\DataLoad\widget.
  2. In the widget directory, open the registerWidgetdef.csv file for editing.
    You use the registerWidgetdef.csv input file to load widget definition information to register your new widget within the Commerce Composer framework. You also use the file to have a store subscribe to the widget. A store must subscribe to a widget for the widget to be available for use in the Commerce Composer tool for that store. The registerWidgetdef.csv input file loads data into the PLWIDGETDEF and PLWIDGETDEFDESC database tables. The generated registerWidgetdef.csv input file includes information that you included in the JET pattern input XML file. You can update the CSV file to include more properties and information for your widget or edit the generated information.
    Ensure that the following columns within the CSV file are correctly specified:
    WidgetDefIdentifier
    The external reference name for the widget definition. You can use any name, but the name must be unique for the store. For example, ShoppingCartDetailWidget. The value for this parameter cannot include spaces or special characters.
    WidgetDisplayName
    The name that displays within the Commerce Composer tool in Management Center to help business users identify the widget. For example, Sample Shopping Cart Detail widget.
    WidgetUIObjectName
    The name that identifies the Management Center object and definition of the widget. For example, ShoppingCartDetailPageWidget. The value for this parameter cannot include spaces or special characters.
    WidgetVendor
    The name of the company or vendor that created the widget. For example, MyCompany. The value for this parameter cannot include spaces or special characters.
    WidgetType
    The type of the widget. The possible values for the property are:
    1
    Widget
    2
    Container
    Ensure that the specified value is 1.
    WidgetPath
    The relative path to the entry point top-level JSP file for the widget. For example, /Widgets-MyCompany/com.mycompany.commerce.store.widgets.ShoppingCartDetail/ShoppingCartDetail.jsp
    WidgetDefinitionxml
    The XML definition for the dynamic properties of the widget. In the example for this tutorial, no additional properties are defined for the Shopping Cart widget so you do not need to specify a value for this column.
    WidgetState
    The state of the widget registration. The possible values for the property are:
    1
    Active.
    2
    Inactive.
    WidgetStoreUniqueID
    The unique reference number of the store in which you are registering the widget. You can use the property to specify whether the widget is to be a site-level or store-level widget. The possible values of the property are:
    storeId
    The store ID value that is defined within the STORE_ID column of the STORE database table. Specify an ID to register the widget within the specified store. The widget is not shared with other stores unless the widget is also registered with another store.
    WebSphere Commerce EnterpriseNote: If you specify an asset store ID, the Data Load utility registers the widget with all extended site stores for that asset store. Each individual extended site store however must still subscribe to the widget separately before the widget can be used for the store.
    0
    Specify a value of 0 to register the widget at the site-level. The registered widget can be shared across all stores in the site.
    Ensure that the specified value is 0.
    WidgetDescription
    The description that displays for the widget within the Commerce Composer tool in Management Center to help business users identify the widget. For example, This widget is for Shopping Cart details.
    Delete
    A flag that indicates whether to delete the widget definition. Specify 1 to delete the widget. The default value is 0, which indicates that the Data Load utility is to load the information for the row into the database.
    Your registerWidgetdef.csv input CSV file can resemble the following file. (Note that the image is split into two rows to fit on this page):
    Sample registerWidgetdef.csv input file.
    Note: The registerWidgetdef.csv subscribes the store that has the identifier that is set within the data load environment configuration file to the widget. If you do not set a value within the environment configuration file, the store that you identify when you run the Data Load utility subscribes to the widget.

    For more information about completing your registerWidgetdef.csv input CSV file, see registerWidgetdef input file.

    For more information about registering a widget and defining the widget definition XML for a widget, see Registering a Commerce Composer widget.

  3. Save and close the CSV file.
  4. Open the subscribeWidgetdef.csv file for editing.
    You use the subscribeWidgetdef.csv input file to subscribe additional stores to the widget. You can also use the CSV input file to override the definition xml of the widget for a store. The subscribeWidgetdef.csv input file loads data into the PLSTOREWIDGET database table. The generated subscribeWidgetdef.csv input file includes information that you included in the JET pattern input XML file. You can update the CSV file to include more information about your widget before you load the CSV file
    Ensure that the following columns within the CSV file are correctly specified:
    WidgetDefIdentifier
    The external reference name for the widget definition. Ensure that the value for the property is the same as the value specified for the widget within the registerWidgetdef.csv file. For example, ShoppingCartDetailWidget. The value for this parameter cannot include spaces or special characters.
    WidgetDefinitionxml
    The XML definition for the dynamic properties of the widget. If you specify a value for the property, you override the value for the WidgetDefinitionxml column in the registerWidgetdef.csv file for a store. For this tutorial, do not specify a value for the property.
    WidgetState
    The state of the widget registration. The possible values for the property are:
    1
    Active.
    2
    Inactive.
    Delete
    A flag that indicates whether to delete the widget definition. Specify 1 to delete the widget. The default value is 0, which indicates that the Data Load utility is to load the information for the row into the database.
    Your subscribeWidgetdef.csv input file can resemble the following file. (Note that the image is split into two rows to fit on this page):
    Sample subscribeWidgetdef.csv input file.
    Note: You do not have to specify the identifier for your store. The Data Load utility uses the value for the store identifier that is set within the data load environment configuration file. If you do not set a value within the environment configuration file, you must enter an identifier when you run the Data Load utility.

    For more information about completing your subscribeWidgetdef.csv input file, see subscribeWidgetdef input file.

  5. Save and close the file.
  6. Configure the Data Load utility so that you can use the utility to load your widget information.
    1. In the DataLoad directory within your new project directory, open the wc-dataload-env.xml file for editing. The wc-dataload-env.xml file is the data load environment configuration file that is generated to help you configure and run the Data Load utility. The configuration file sets the environment variables that the Data Load utility uses, such as the database settings, ID resolver, and data writer.
    2. Update the file to match your database and environment settings. Uncomment and update the appropriate setting for your database.
      Your complete wc-dataload-env.xml file can resemble the following code:
      <_config:DataLoadEnvConfiguration
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../../../xml/config/xsd/wc-dataload-env.xsd"
        xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config">
        <_config:BusinessContext storeIdentifier="Aurora" languageId="-1">
        </_config:BusinessContext>
      	    
        <!-- database setting for derby in Toolkit -->
      	  <_config:Database type="derby" name="..\db\mall" schema="APP"/>
        
        <!-- database setting for Oracle -->
        <!--
          <_config:Database name="<database name>" user="<user>" password="<password>" port="1521" schema="<schema name>" server="<server>" type="Oracle" dbDriverType="thin" />
        -->
        
        <!-- database setting for AIX/DB2 server -->
        <!--
          <_config:Database type="db2" name="<database name>" user="<user>" password="<password>" server="<server>" port="<port>" schema="<schema>" />
        -->
        
        <_config:IDResolver className="com.ibm.commerce.foundation.dataload.idresolve.IDResolverImpl" cacheSize="0"/>
        <_config:DataWriter className="com.ibm.commerce.foundation.dataload.datawriter.JDBCDataWriter" />
      </_config:DataLoadEnvConfiguration>
    3. Optional: In the DataLoad directory within your new project directory, open the wc-loader-registerWidgetdef.xml and wc-loader-subscribeWidgetdef.xml files to review the generated code.
      The wc-loader-registerWidgetdef.xml and wc-loader-subscribeWidgetdef.xml files are the business object configuration files for loading information to register a widget and subscribe to a widget. A business object configuration file defines how the Data Load utility loads information into the database. Within the files, the implementation classes are specified for the Data Reader, Business Object Builder, and Business Object Mediator components. Within the business object configuration files, you can specify more attributes and properties for these components.

      For more information about creating a data load environment configuration file, see Configuring the data load environment settings.

    4. Optional: In the DataLoad\widget directory within your new project directory, open the wc-dataload-widget.xml file to review the generated code.
      The generated wc-dataload-widget.xml file is the data load order configuration file that controls the order that the Data Load utility loads information. The configuration file includes a pointer to the data load environment configuration file, business object configuration files, and the input CSV files. Your generated data load order configuration file can resemble the following code:
      <_config:DataLoadConfiguration
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-dataload.xsd"
        xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config">
        <_config:DataLoadEnvironment configFile="../wc-dataload-env.xml" />
        <_config:LoadOrder commitCount="100" batchSize="1" dataLoadMode="Replace">
          <_config:property name="charset" value="UTF-8" />
          <_config:property name="loadSEO" value="true" />
          <!-- Register the Widget -->
          <_config:LoadItem name="RegisterWidgetDef" businessObjectConfigFile="../wc-loader-registerWidgetdef.xml">
            <_config:DataSourceLocation location="registerWidgetdef.csv" />
          </_config:LoadItem>
          <!-- Subscribe the widget to store -->
          <_config:LoadItem name="SubscribeWidgetDef" businessObjectConfigFile="../wc-loader-subscribeWidgetdef.xml">
            <_config:DataSourceLocation location="subscribeWidgetdef.csv" />
          </_config:LoadItem>
        </_config:LoadOrder>
      </_config:DataLoadConfiguration>
      
      For more information about creating a data load order configuration file, see Configuring the data load order.
    5. Save any files that you edited and close all of the files.
  7. Run the Data Load utility.
    1. Ensure that your WebSphere Commerce Server is stopped before you run the Data Load utility. For more information about stopping your server, see Starting and stopping WebSphere Commerce Test Server.
    2. In a command-line utility, go to the WCDE_installdir\bin directory.
    3. Run the following command to load the input CSV files to register your widget and have a store subscribe to your widget:
      Dataload.bat workspace_dir\NewWidgetProject\DataLoad\widget\wc-dataload-widget.xml 
    4. Verify the results of the data load.