Tutorials > Management Center > Add a Recipes tool to the Management Center

< Previous | Next >


Define the main Recipes tool definition

In this lesson, 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.

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:

    • In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx > mycompany > recipe.

    • In the Enterprise Explorer view, expand LOBTools > WebContent > config > mycompany > recipe.

  3. Right-click the recipe folder and complete one of the following steps:

    • Select New > File to create an OpenLaszlo class file named RecipeManagementToolDefinition.lzx.

    • Select 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 the changes.

    Option Description
    RecipeManagementToolDefinition.lzx

    <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> 
    

    RecipeManagementToolDefinition.def

    <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. In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx > commerce > shell.

      2. In the Enterprise Explorer view, expand LOBTools > WebContent > config > commerce > shell.

    2. Double-click one of the following files to edit the file:

      • ApplicationMenuItems.lzx

      • ApplicationMenuItems.def

    3. Add the 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.

      <!---
              Application menu item for opening the Recipe Management tool.
              Customization Part.
      -->
      <wcfApplicationMenuItem
              
              width="${parent.width}"
              height="25"
              activeIconSrc="recipeActiveTabIcon"
              inactiveIconSrc="recipeInactiveTabIcon"
              displayName="${extRecipeResources.recipe_DisplayName.string}"
              usage="MyCompany_RecipeTool"
              objectClass="recRecipeManagement"
              actionName="openBusinessObjectEditor" />   
      

      <!---
              Application menu item for opening the Recipe Management tool.
              Customization Part.
      -->
      <ApplicationMenuItem
              
              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 Create a new user with the Recipe Manager role to access the Recipes tool.

  6. Right-click the LOBTools project and select Build OpenLaszlo Project.

< Previous | Next >


+

Search Tips   |   Advanced Search