Defining top and organizational objects in the explorer view

In this lesson, you will define the top object definition and the organization object definition in the Management Center explorer view.

About this task

In this lesson, you will create the new Recipes tool as the following tree structure in the explorer view.

Screen capture displaying the Recipes tool.

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

  1. 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.
  2. Create the following directory structure, if it does not exist:
    • WebSphere Commerce Version 7.0.0.0Feature Pack 1objectDefinitions/
    • Feature Pack 3Feature Pack 2mycompany/recipe/objectDefinitions
  3. Right-click the objectDefinitions folder and select Import. Expand General and select File system.
  4. Click Next, then click Browse and navigate to:
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1TutorialSource\LOBTools\WebContent\WEB-INF\src\lzx\mycompany\recipe\objectDefinitions, where TutorialSource is the location where you unzipped the Tutorial sample source code WebSphere Commerce Version 7.0.0.0Feature Pack 1
    1. Select the RecipeTopObjectDefinition.lzx file.
    2. Click Finish to import the file.
    Feature Pack 3Feature Pack 2TutorialSource\LOBTools\WebContent\config\mycompany\recipe\objectDefinitions, where TutorialSource is the location where you unzipped the Tutorial sample source code Feature Pack 3Feature Pack 2
    1. Select the RecipeTopObjectDefinition.def file.
    2. Click Finish to import the file.
  5. Open one of the following files and examine the contents:
    • WebSphere Commerce Version 7.0.0.0Feature Pack 1RecipeTopObjectDefinition.lzx (top object class file)
    • Feature Pack 3Feature Pack 2RecipeTopObjectDefinition.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:

    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1RecipeTopObjectDefinition.lzx WebSphere Commerce Version 7.0.0.0Feature Pack 1
    <!--
    ===================================================================
    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>
    Feature Pack 3Feature Pack 2RecipeTopObjectDefinition.def Feature Pack 3Feature Pack 2
    <!--
    ===================================================================
    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:
    • WebSphere Commerce Version 7.0.0.0Feature Pack 1A 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.
    • Feature Pack 3Feature Pack 2A 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.
    Note: Only one top object definition can be declared for each wcfBusinessObjectEditor.
  6. Two more organizational objects are defined (one for Unassigned Recipes, the other for Recipe By Collections) in one of the following files:
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1RecipeTopObjectDefinition.lzx (top object class file) WebSphere Commerce Version 7.0.0.0Feature Pack 1Unassigned 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.
    Feature Pack 3Feature Pack 2RecipeTopObjectDefinition.def (top object definition file) Feature Pack 3Feature Pack 2Unassigned 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 RecipeCollectionNode
    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.
  7. WebSphere Commerce Version 7.0.0.0Feature Pack 1Right-click the LOBTools project and select Build OpenLaszlo Project.

Results