Tutorials > Management Center > Add a Recipes tool to the Management Center
Define top and organizational objects in the explorer view
In this lesson, we will define the top object definition and the organization object definition in the Management Center explorer view.
In this lesson, we will create the new Recipes tool as the following tree structure in the explorer view.
A top object definition is an organizational object definition that describes the root object for an instance of wcfBusinessObjectEditor. This root object is the starting point for populating the navigation tree.
As shown in the preceding screen capture, there are another two organizational objects under the top object, Recipe By Collections, and Unassigned Recipes.
Procedure
- 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.
- Create the following directory structure, if it does not exist:
- objectDefinitions/
- mycompany/recipe/objectDefinitions
- Right-click the objectDefinitions folder and select Import. Expand General and select File system.
- Click Next, then click Browse and navigate to:
Option Description TutorialSource\LOBTools\WebContent\WEB-INF\src\lzx\mycompany\recipe\objectDefinitions, where TutorialSource is the location where you unzipped the Tutorial sample source code
- Select the RecipeTopObjectDefinition.lzx file.
- Click Finish to import the file.
TutorialSource\LOBTools\WebContent\config\mycompany\recipe\objectDefinitions, where TutorialSource is the location where you unzipped the Tutorial sample source code
- Select the RecipeTopObjectDefinition.def file.
- Click Finish to import the file.
- Open one of the following files and examine the contents:
- RecipeTopObjectDefinition.lzx (top object class file)
- RecipeTopObjectDefinition.def (top object definition file)
A top object named recRecipeTopObjectdefinition is defined in these files.
The following code samples show the top object defined in each of these files:
Option Description RecipeTopObjectDefinition.lzx
<!-- =================================================================== The current TopObjectDefinition includes two organizational objects =================================================================== --> 1 <class name="recRecipeTopObjectDefinition" extends="wcfTopObjectDefinition"> <!-- Initialize the Instance of the OrganizationalObject--> <dataset name="template"> <object objectType="UnassignedRecipeNode" /> <object objectType="RecipeCollectionNode" /> </dataset> <wcfGetChildrenService url="/cmc/GetMasterCatalogObject"> <wcfServiceParam name="storeId" /> </wcfGetChildrenService> <!--- Retrieves the {@link catSalesCatalogPrimaryObjectDefinition Sales Catalog} child objects. --> <wcfGetChildrenService url="/cmc/GetSalesCatalogs"> <wcfServiceParam name="storeId" /> <wcfServiceParam name="defaultLanguageId" /> </wcfGetChildrenService> </class>
RecipeTopObjectDefinition.def
<!-- =================================================================== The current TopObjectDefinition includes two organizational objects =================================================================== --> 1 <TopObjectDefinition definitionName="recRecipeTopObjectDefinition"> <!-- Initialize the Instance of the OrganizationalObject--> <Xml name="template"> <object objectType="UnassignedRecipeNode" /> <object objectType="RecipeCollectionNode" /> </Xml> <GetChildrenService url="/cmc/GetMasterCatalogObject"> <ServiceParam name="storeId" /> </GetChildrenService> <!--- Retrieves the Sales Catalog child objects. --> <GetChildrenService url="/cmc/GetSalesCatalogs"> <ServiceParam name="storeId" /> <ServiceParam name="defaultLanguageId" /> </GetChildrenService> </TopObjectDefinition>
- 1 recRecipeTopObjectDefinition
- Rrepresents the whole navigation tree of the recipe tool. The tree has two kinds of organizational objects as the second layer nodes: unassigned recipes and collection managed recipes. You need to add these two kinds of organizational objects under this top object in the dataset by defining the <object> with the corresponding object type.
This top object definition only has child objects which are organizational objects and there is no need to invoke a service on the WebSphere Commerce server to get these children. This is due to the fact that these organizational objects do not have a server side representation.
To facilitate this:
- A dataset is created that contains the XML representation of these child objects. When the top object is created, the dataset causes the Management Center framework to create the child objects that are within the dataset. It has two wcfGetChildrenService to retrieve the data from the master catalog and sales catalog, which is used to load the catalog objects into the utility panel.
- A template is created that contains the XML representation of these child objects. When the top object is created, the template causes the Management Center framework to create the child objects that are within the template. It has two GetChildrenService elements to retrieve the data from the master catalog and sales catalog, which is used to load the catalog objects into the utility panel.
Only one top object definition can be declared for each wcfBusinessObjectEditor.
- Two more organizational objects are defined (one for Unassigned Recipes, the other for Recipe By Collections) in one of the following files:
Option Description RecipeTopObjectDefinition.lzx (top object class file) Unassigned Recipes:
< 1 class name="recUnassignedRecipeOrganizationalObjectDefinition" extends="wcfOrganizationalObjectDefinition" objectType="UnassignedRecipeNode" organizedObjectTypes="Recipe" displayName="${extRecipeResources.recipeNotInCollection_DisplayName.string}"> <!-- GetChildren service --> 2 <wcfGetChildrenService url="/cmc/GetUnassignedRecipes" > <wcfServiceParam name="storeId"/> </wcfGetChildrenService> <!-- Include the list view definition to display the children objects--> <recUnassignedRecipeNavigationList /> <wcfUnassignedObjectFilter/> </class>
- 1 recUnassignedRecipeOrganizationalObjectDefinition
- Represents a node in a navigation tree that contains the recipes that are not assigned to recipe collections.
- 2 <wcfGetChildrenService url="/cmc/GetUnassignedRecipes" >
- Gets all the unassigned recipes in the system. This service is already defined in the prerequisite tutorial and is mapped to the URL "/cmc/GetUnassignedRecipes" in another lesson.
Recipe By Collections:
< 3 class name="recRecipeCollectionOrganizationalObjectDefinition" extends="wcfOrganizationalObjectDefinition" objectType="RecipeCollectionNode" organizedObjectTypes="RecipeCollection" displayName="${extRecipeResources.recipeCollection_TreeNode.string}"> <!-- GetChildren service --> 4 <wcfGetChildrenService url="/cmc/GetRecipeCollections" objectTypes="RecipeCollection"> <wcfServiceParam name="storeId"/> </wcfGetChildrenService> <!-- Define the list view definition to display the children objects--> <wcfNavigationListDefinition name="recCollectionNavigationList" listTitle="${extRecipeResources.recipeCollection_DisplayName.string}" displayName="${extRecipeResources.recipeCollection_DisplayName.string}" listClass="recCollectionList" toolbarIcon="listToolbarIcon" /> </class>
- 3 recRecipeCollectionOrganizationalObjectDefinition
- Represents the node Recipe by Collection on the navigation tree. Its child nodes are all the recipe collections in the system.
- 4 /cmc/GetRecipeCollections
- Gets all the recipe collections in the system. This service is already defined in the prerequisite tutorial and is mapped to the URL "/cmc/GetRecipeCollections" in another lesson.
RecipeTopObjectDefinition.def (top object definition file) Unassigned Recipes:
<OrganizationalObjectDefinition 1 definitionName="UnassignedRecipeNode" objectType="UnassignedRecipeNode" organizedObjectTypes="Recipe" displayName="${extRecipeResources.recipeNotInCollection_DisplayName}"> <!-- GetChildren service --> 2 <GetChildrenService url="/cmc/GetUnassignedRecipes" > <ServiceParam name="storeId"/> </GetChildrenService> <!-- Include the list view definition to display the children objects--> <NavigationListDefinition baseDefinitionName="recUnassignedRecipeNavigationList"/> <UnassignedObjectFilter/> </OrganizationalObjectDefinition>
- 1 UnassignedRecipeNode
- Represents a node in a navigation tree that contains the recipes that are not assigned to recipe collections.
- 2 <GetChildrenService url="/cmc/GetUnassignedRecipes" >
- Gets all the unassigned recipes in the system. This service is already defined in the prerequisite tutorial and is mapped to the URL "/cmc/GetUnassignedRecipes" in another lesson.
Recipe By Collections:
3 <OrganizationalObjectDefinition definitionName="RecipeCollectionNode" objectType="RecipeCollectionNode" organizedObjectTypes="RecipeCollection" displayName="${extRecipeResources.recipeCollection_TreeNode}"> <!-- GetChildren service --> 4 <GetChildrenService url="/cmc/GetRecipeCollections" objectTypes="RecipeCollection"> <ServiceParam name="storeId"/> </GetChildrenService> <!-- Define the list view definition to display the children objects--> <NavigationListDefinition name="recCollectionNavigationList" listTitle="${extRecipeResources.recipeCollection_DisplayName}" displayName="${extRecipeResources.recipeCollection_DisplayName}" listDefinitionName="recCollectionList" toolbarIcon="listToolbarIcon"/> </OrganizationalObjectDefinition>
- 3 recRecipeCollectionOrganizationalObjectDefinition
- Represents the node Recipe by Collection on the navigation tree. Its child nodes are all the recipe collections in the system.
- 4 /cmc/GetRecipeCollections
- Gets all the recipe collections in the system. This service is already defined in the prerequisite tutorial and is mapped to the URL "/cmc/GetRecipeCollections" in another lesson.
- Right-click the LOBTools project and select Build OpenLaszlo Project.