Tutorials > Management Center > Add a Recipes tool to the Management Center
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.
- 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
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- 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.
- 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.
- 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>
- Add the new Recipes tool to the application menu:
- Complete one of the following steps:
- In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx > commerce > shell.
- In the Enterprise Explorer view, expand LOBTools > WebContent > config > commerce > shell.
- Double-click one of the following files to edit the file:
- ApplicationMenuItems.lzx
- ApplicationMenuItems.def
- 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.
- Right-click the LOBTools project and select Build OpenLaszlo Project.