Creating the gift reward grid classIntroduced in Feature Pack 3Feature Pack 2 or list view definition for the user interface

In this lesson, you create the Management Center user interface element in which business users specify the free gift and quantity information for the promotion.

This Management Center user interface element is:
  • WebSphere Commerce Version 7.0.0.0Feature Pack 1A grid class that is used in a properties view class that you create in the next lesson.
  • Introduced in Feature Pack 3Feature Pack 2A list view that is used in a properties view definition that you create in the next lesson.

About this task

For this new promotion type, business users can specify a gift comprising multiple (different) catalog entries in varying quantities. To support this in the user interface, you need a grid with the following three columns:
  • Type
  • Catalog entry
  • Quantity for free

By default, the Promotions tool has a gift reward grid. The grid contains two columns: Type and Catalog entry. To support your new promotion type, add an additional column called Quantity for free.



You must also customize this gift grid to allow business users to add additional rows, to accommodate multiple (different) catalog entries as gifts. This is covered in the next lesson, Creating the promotion properties view for the user interface.

Procedure

  1. Complete one of the following steps:
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1Create a folder for the gift reward grid class WebSphere Commerce Version 7.0.0.0Feature Pack 1
    1. In the Enterprise Explorer view, navigate to the LOBTools > WebContent > WEB-INF > src > lzx > mycompany > promotion directory.
    2. Right-click the promotion folder and click New > Folder.
    3. In the Folder name field, type listViewDefinitions.
    4. Click Finish. The directory structure should now look like this screen capture:
      listViewDefinitions folder
    Introduced in Feature Pack 3Feature Pack 2Create a folder for the gift reward list view definition Introduced in Feature Pack 3Feature Pack 2
    1. In the Enterprise Explorer view, navigate to the LOBTools > WebContent > config > mycompany > promotion directory.
    2. Right-click the promotion folder and click New > Folder.
    3. In the Folder name field, type listViewDefinitions.
    4. Click Finish. The directory structure should now look like this screen capture:
      listViewDefinitions folder
  2. Complete one of the following steps:
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1Create a new OpenLaszlo file to define the new gift grid WebSphere Commerce Version 7.0.0.0Feature Pack 1
    1. Right-click the listViewDefinitions folder.
    2. Click New > File.
    3. Click New > Other.
    4. In the "Select a wizard" window, expand the Simple folder and click File.
    5. Click Next.
    6. Name your new file ChildListEditorListViews.lzx.
    7. Click Finish to save the file. The file opens in the default XML editor.
    Introduced in Feature Pack 3Feature Pack 2Create a new definition file to define the new gift list view Introduced in Feature Pack 3Feature Pack 2
    1. Right-click the listViewDefinitions folder.
    2. Click New > File.
    3. Name your new file ChildListEditorListViews.def.
    4. Click Finish to save the file. The file opens in the default XML editor.
  3. To define the gift reward grid:
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1ChildListEditorListViews.lzx WebSphere Commerce Version 7.0.0.0Feature Pack 1In this new class file:
    1. Copy and paste the following code:
      
      <library>
         <class name="extProGiftRewardGrid" extends="proProductGrid" preferenceKey="extProductGrid">
           <wcfGridStepper name="giftQuantity" propertyName="giftQuantity" minimumValue="1"
               editable="true" visible="true" width="200" required="true" 
               text="${extPromotionResources.promotion_Free_gift_qty.string}" />
         </class>
      </library>
      
    2. Save and close the file.

    This class extends the proProductGrid class, which the Promotions tool provides. This class displays the contents and characteristics of a list of SKUs, products, or kits as promotion gifts. On this grid, the code above adds a new column named giftQuantity to capture this value. The wcfGridStepper class is used as an input widget to allow business users to enter an integer for the gift quantity. This column is defined as a mandatory entry, and the minimum value is 1.

    Introduced in Feature Pack 3Feature Pack 2ChildListEditorListViews.def Introduced in Feature Pack 3Feature Pack 2In this new definition file:
    1. Copy and paste the following code:
      <Definitions>
          <ObjectGrid definitionName="extProGiftRewardGrid" baseDefinitionName="proProductGrid"
              preferenceKey="extProductGrid">
           <GridStepper name="giftQuantity" propertyName="giftQuantity" minimumValue="1"
               editable="true" visible="true" width="200" required="true"
               text="${extPromotionResources.promotion_Free_gift_qty}"/>
          </ObjectGrid>
      </Definitions>
    2. Save and close the file.

    This definition extends proProductGrid definition, which the Promotions tool provides. This definition displays the contents and characteristics of a list of SKUs, products, or kits as promotion gifts. On this grid, the previous code sample adds a new column named giftQuantity to capture this value. The wcfGridStepper class is used as an input widget to allow business users to enter an integer for the gift quantity. This column is defined as a mandatory entry, and the minimum value is 1.

  4. WebSphere Commerce Version 7.0.0.0Feature Pack 1Right-click the ChildListEditorListViews.lzx file; then click Build OpenLaszlo Project on the context menu.
  5. WebSphere Commerce Version 7.0.0.0Feature Pack 1 Register the grid class file in the promotion extensions library:
    1. In the PromotionExtensionsLibrary.lzx file, which should still be open from a previous step, add the following include statement within the <library> element:
      <include href="../../mycompany/promotion/listViewDefinitions/ChildListEditorListViews.lzx"/>
    2. Save the file.
    3. Right-click the PromotionExtensionsLibrary.lzx file; then click Build OpenLaszlo Project on the context menu.

Results

In this lesson, you created the Management Center widget where business users can specify the promotion gifts and their quantity. In the next lesson, you create the remaining Management Center user interface widgets to support your promotion.