Defining the main Recipes tool definition

In this lesson, you need to define the main definition for the Recipes tool. The tool definition must extend the wcfBusinessObjectEditor class, which is the base class for all Management Center tools. The business object editor includes support for the menu, toolbar, search widget, explorer view and utilities view. It is responsible for managing all user interactions that allow the user to edit the business objects declared with this business object editor.

About this task

  • A single instance of wcfTopObjectDefinition must be declared as a child of every business object editor. When the business object editor is initialized, an instance of this top object is instantiated.
  • At least one instance of wcfFilter must be declared as a child of every business object editor. This filter is used to filter the objects displayed in the explorer view and utilities view browse tab.
  • Multiple instances of wcfOrganizationalObjectDefinition can be declared as children of a business object editor. Organization objects are instantiated only by declaring them in the template of the top object definition or of another organizational object definition.
  • At least one instance of wcfPrimaryObjectDefinition must be declared as a child of every business object editor. There must be a primary object definition for every type of business object that can be returned through a search request or can be located by browsing for objects through the explorer view or utilities view.
  • Multiple instances of wcfSearchDefinition can be declared as children of a business object editor. The search definitions are used to populate the list of search types available from the search area and utilities view search tab.

To create the main tool definition class file:

Procedure

  1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
  2. Complete one of the following steps:
    • WebSphere Commerce Version 7.0.0.0Feature Pack 1In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx > mycompany > recipe.
    • Feature Pack 3Feature Pack 2In the Enterprise Explorer view, expand LOBTools > WebContent > config > mycompany > recipe.
  3. Right-click the recipe folder and complete one of the following steps:
    • WebSphere Commerce Version 7.0.0.0Feature Pack 1Select New > File to create an OpenLaszlo class file named RecipeManagementToolDefinition.lzx.
    • Feature Pack 3Feature Pack 2Select New > File to create a definition file named RecipeManagementToolDefinition.def.
  4. Copy and paste the following sample code into one of the following files and save your changes.
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1RecipeManagementToolDefinition.lzx WebSphere Commerce Version 7.0.0.0Feature Pack 1
    <library>
    <class name="recRecipeManagement" extends="wcfBusinessObjectEditor"
    helpLink="" displayName="${extRecipeResources.recipe_DisplayName.string}"
    browseUtilityFilterTypes="MasterCategories,SalesCategories,Recipes"
    explorerFilterTypes="Recipes">
    
    <!-- Context value for the master catalog id -->
    <wcfContextValue parameterName="masterCatalogId"/>
    
    <catCatalogInitService/>
    
    <!-- Filter definitions -->
    <wcfObjectTypeFilter filterType="Recipes" displayName="Recipes" isDefault="true"
    objectTypes="RecipeCollectionNode,UnassignedRecipeNode,RecipeCollection" />
    <catMasterCatalogGroupsFilter />
    <catSalesCatalogGroupsFilter />
    
    <!-- Recipe Top Objects -->
    <recRecipeTopObjectDefinition/>
    
    <!-- Recipe Organizational Objects -->
    <recUnassignedRecipeOrganizationalObjectDefinition/>
    <recRecipeCollectionOrganizationalObjectDefinition/>
    
    <!-- Recipe Primary Objects -->
    <recRecipeCollectionPrimaryObjectDefinition/>
    <recRecipePrimaryObjectDefinition/>
    
    <!-- search definitions -->
    <recFindRecipesSearchDefinition/>
    <recFindRecipeCollectionsSearchDefinition/>
    
    </class>
    </library> 
    Feature Pack 3Feature Pack 2RecipeManagementToolDefinition.def Feature Pack 3Feature Pack 2
    <Definitions>
    <BusinessObjectEditor browseUtilityFilterTypes="MasterCategories,SalesCategories,Recipes" definitionName="recRecipeManagement" displayName="${extRecipeResources.recipe_DisplayName}" explorerFilterTypes="Recipes" helpLink="">
    
    <!-- Context value for the master catalog id -->
    <ContextValue parameterName="masterCatalogId"/>
    
    <InitService baseDefinitionName="catCatalogInitService"/>
    
    <!-- Filter definitions -->
    <ObjectTypeFilter displayName="Recipes" filterType="Recipes" isDefault="true" objectTypes="RecipeCollectionNode,UnassignedRecipeNode,RecipeCollection"/>
    <ObjectTypeFilter baseDefinitionName="catMasterCatalogGroupsFilter"/>
    <ObjectTypeFilter baseDefinitionName="catSalesCatalogGroupsFilter"/>
    
    <!-- Recipe Top Objects -->
    <TopObjectDefinition baseDefinitionName="recRecipeTopObjectDefinition"/>
    
    <!-- Recipe Organizational Objects -->
    <OrganizationalObjectDefinition baseDefinitionName="UnassignedRecipeNode"/>
    <OrganizationalObjectDefinition baseDefinitionName="RecipeCollectionNode"/>
    
    <!-- Recipe Primary Objects -->
    <PrimaryObjectDefinition baseDefinitionName="RecipeCollection"/>
    <PrimaryObjectDefinition baseDefinitionName="Recipe"/>
    
    <!-- search definitions -->
    <SearchDefinition baseDefinitionName="FindRecipes"/>
    <SearchDefinition baseDefinitionName="FindRecipeCollections"/>
    
    </BusinessObjectEditor>
    </Definitions>
  5. Add the new Recipes tool to the application menu:
    1. Complete one of the following steps:
      1. WebSphere Commerce Version 7.0.0.0Feature Pack 1In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx > commerce > shell.
      2. Feature Pack 3Feature Pack 2In the Enterprise Explorer view, expand LOBTools > WebContent > config > commerce > shell.
    2. Double-click one of the following files to edit the file:
      • WebSphere Commerce Version 7.0.0.0Feature Pack 1ApplicationMenuItems.lzx
      • Feature Pack 3Feature Pack 2ApplicationMenuItems.def
    3. Add your new menu definition to the file. Find the line containing the text Application menu item for launching WebSphere Commerce Accelerator and copy the following code sample before this line.
      WebSphere Commerce Version 7.0.0.0Feature Pack 1
      
      <!---
              Application menu item for opening the Recipe Management tool.
              Customization Part.
      -->
      <wcfApplicationMenuItem
              id="recipeManagement"
              width="${parent.width}"
              height="25"
              activeIconSrc="recipeActiveTabIcon"
              inactiveIconSrc="recipeInactiveTabIcon"
              displayName="${extRecipeResources.recipe_DisplayName.string}"
              usage="MyCompany_RecipeTool"
              objectClass="recRecipeManagement"
              actionName="openBusinessObjectEditor" />   
      
      Feature Pack 3Feature Pack 2
      <!---
              Application menu item for opening the Recipe Management tool.
              Customization Part.
      -->
      <ApplicationMenuItem
              id="recipeManagement"
              activeIconSrc="recipeActiveTabIcon"
              inactiveIconSrc="recipeInactiveTabIcon"
              displayName="${extRecipeResources.recipe_DisplayName}"
              usage="MyCompany_RecipeTool"
              toolDefinitionName="recRecipeManagement"
              actionName="openBusinessObjectEditor" />
      Tip: The attribute usage="MyCompany_RecipeTool" refers to the name of the usage policy that is used to determine access to this menu item. You have already created the policy, MyCompany_RecipeTool, in the lesson Creating a user with the Recipe Manager role to access the Recipes tool.
  6. WebSphere Commerce Version 7.0.0.0Feature Pack 1Right-click the LOBTools project and select Build OpenLaszlo Project.